added option to write to stdout