writeToFile() modified