Changing file operations to use `with`

* Open and Close is always flaky. We tend to forget. With is a better
  way to do these things
Merge pull request #4 from shrayas/master

Changing file operations to use `with` instead of `open` and `close`