Ensure file handles are closed using with statement

This change ensures the file handles are closed properly in setup.py.