Script to read external file and put values into variables/switches

Hello!

Me and a friend is working on something quite interesting. I'm right now researching how to read external files in order to
take the data in that file and change variables in switches. Set variables to different numbers, turn switches on and off.

The script needs to be active as it has to be able to check the file for changes rather frequently.

A script call function to load the file in RPGmaker and write a reset to that variable or switch could be useful as well so it can be turned off by the game. Or even locked for a certain time of frames. 

As I can see without ingame control the constant reading of the file would keep overriding any type of event that has several stages. 

Is there something out there that already does something similar?
Or does anyone have any helpful advice/information?

Me and my friend will try to make this work ourselves, at this moment we are in the research stage.

Cheers!
And thank you for your time =)
you can use the following script as a guideline how to do that:


http://forums.rpgmakerweb.com/index.php?/topic/6608-external-text-now-v21-unicode-fix/
Thank you for the link mate. It did help a little bit. 

This is as far as I've come today. Note that this is the first thing I ever started writing on my own for RPGMVXA:
http://pastebin.com/VB0rne1F

What it does is that it writes to a file just for testing purpose really. Than the text from that file is put into variable(s).
Now I'm having an error where I can't even start the application if I comment out the first Marshal.dump("Test", file)
The error that pops up says EOFError (End of file): I don't understand how that could be because the file has already been populated since earlier when ran the program before I took out the Marshal.dump. 

Any ideas?
Are you planning to encrypt your data?


Are players allowed to manually tamper with the file you're reading/writing?
Encryption definitely not necessary on my end. 
And yes if by manually means by fulfilling whatever event is enabled or changed the player should essentially reset it.Ultimately it would be nice if there is a frame counter or somesuch dictating how long between it can re-read and set the variable. kind of like locking it in place outside of manipulation for a moment.

 Good questions, thank you Tsukihime =)

EDIT:
This is where I'm at now. Mind you this is still my first entirely own venture into scripting for VX ACE. I'm able to load files, I'm able to set an array of variables and switches. I could probably quite easily make a function to allow the variables to be strings as well. But that comes later. 

Next I need to figure out how to read this file every set amount of frames. Maybe it would be easiest to call it from a script call every X amount of frames? Can't find any information on how to make that possible. 

Best would be whenever there is a change in the file but I think that is to difficult to setup. Guess I could check the filedate and save it in a variable and if the filedate is newer it will load it. That way I won't have to load the entire file to look for changes.

After that I will delve into how to parse the text file(s) further to set specific variables/switches.

Here's the current code (delete the odd space at the end of the url dunno what is up with that):

http://pastebin.com/3yUXV5Tc

Original thread: https://forums.rpgmakerweb.com/threads/script-to-read-external-file-and-put-values-into-variables-switches.24342/