Query results printing to file