write results to a file