Also, JScript doesn't define the IO mode constants for the FileSystemObject, so you need to define them yourself:
js code:
// In the global scope
var ForAppending = 8;
// Where you need to read the text file
theFile = fso.OpenTextFile(MsgPlus.ScriptFilesPath + "\\data.txt", ForAppending, true);
or use their numerical value directly:
js code:
theFile = fso.OpenTextFile(MsgPlus.ScriptFilesPath + "\\data.txt", 8, true);
Source: FileSystemObject.OpenTextFile on DevGuru