Completed printToFile