Changed the stream closing code in the copyFile method