#update writeFile function