Ensure file handle is closed using with statement

This commit ensures the file handle in `setup.py` is always closed.