Fixed file closing