fixed not closing files