Added support for writing results to an output file