Ensure file handle is closed by using with statement

This change ensure the file handle in `setup.py` is closed.