Included option to write output to file instead stdout.
Included option to write output to file instead of stdout.