replace print statements with output to stderr with sys.stderr.write calls