add option to write output