Ensure file handles are closed using with statement

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