better printing to file