renamed argument  to
adding tests for broken pipe errors and such
output_to_file argument is now thrown away