Reindent code to use spaces rather than tabs
Change method signature to use filelike objects

Better to define the method as using filehandles, as it allows
more flexibility in the way they can be used (streams, strings, files...)
Use line continuation and string interpolation
Add main method using ArgumentParser

We want to be able to run this directly from the command-line,
and to have hints on what to give the script.

Use argparse to achieve that.