Ensure file handles in setup.py are closed

This changes ensures file handles in `setup.py` are closed.