fixed not closing files issue