modified method of printing to file
modified method of printing to file