Use tempfile for creating a file in home directory for a IO test
- [X] closes #40091
- [X] tests added / passed
- [X] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [X] whatsnew entry

lgtm ping on greenish (there is a failing numpy_dev build ATM) thanks @chrispe very nice!