Writing to file and closing file added.