Ensure file handle is closed using with statement

This change ensures that the file handle is closed in setup.py.