Context managers - they close files

And fix a bug in the code - Its not just style.  the first file was never closed.  The context manager (with statement) automatically closes the file... even if there is an error!