added command line option to save the output to a file