Writing a variable out to a .txt file

Can I ask why you have this requirement? If it’s just to pass vars between scripts, I’ve got a topic on the best way to do that: