fix a bug of closing file.