Fixed Append operation in writeFile