WriteToFile fixed