added the -o option to write the output to stdout