Added .close() to fin/fout failures