I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
As I said, you need to give more information. WHAT is the purpose of writing it to a text file so it can be read later? Why can't you just use the variable, or store it in another variable and use that? How do you get around the issue where there are several games in progress and they are all writing this variable to the same text file (though it might have a different value) and then reading it back? You might end up with one game reading a variable that was set by a different game.
Please explain what you want to achieve, as there may be a better way around it.