option to write to stdout or a file stream