Fixed the file appending