You have to read all the relevant documentation several times before you get the full picture. Slowly it will become clearer.
I wasn't actually suggesting Writefile as a solution to your problem - just pointing out it's one of the few ways to get data
out of the run-time environment.