TextFile: Fix a potential bug when reopening a file as text.

Copy the filename before reopening the file since not doing that can lead to an incorrect memory access because the filename is emptied during the process.

Backport of MPC-HC commit 2a75078