fix defect for closing file