added printToFile function as method as extension method to String