Add WriteToFile function.