Added the ability to easily switch between printing to stdout and a file.