closing file after writing