Not sure why, I can't spot any infinite loops Edit: I removed line 53 and changed line 57 to:
FileInputStream fileInputStream = new FileInputStream(s);
now it's failing all the conditions except the first and last with the mentor recommendation: The file output stream was not closed.