Added an argument to output to any filelike object.

Defaults to sys.stdout. 
My editor added a newline to the end of the file, which is PEP8 compliant, so I left it in.