Writing results to a file