Added option to save to an output file