Ensure file handles are closed in setup.py

This change ensures the file handles are closed properly in setup.py.
It is better to use a context manager.