Ensure file handle is closed using with statement

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