add -f flag to write to file, and make sure we print out stderr as well