fix not closing file