Ensure file handles are closed using with statement

This change ensures the file handles in `setup.py` are closed using the with statement. By fixing it here it means many projects based on this will automatically have their file handles closed properly.