Fix close file bug