Use `with` instead of manually closing the file

`with` assures that the __exit__(...) method will be called on objects
once the block is exited. In the case of files, that will call the
close() method so that you don't have to remember to do it yourself.