fixed file closing