Ensure file handles are closed using with statement

This change ensures the file handles are closed properly in setup.py.
I think this can stay a one-liner, but maybe switch to `io.open` instead?