Updated writing results to output files