added closing the file after appending