The output stream for the first file is not closed!!! Why line 40 is not working?