You could try this, don't think it will work but its cleaner and nicer...
code:
function AddLineToFile (file, line)
{
if (!fsObj.FileExists(MsgPlus.ScriptFilesPath + '\\' + file))
{
var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 2, 1);
}
else
{
var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 8, 0);
fileObj.WriteLine(MsgPlus.RemoveFormatCodes(line));
fileObj.Close();
}
}
Also, if you wanted to just replace some characters, you could try
code:
str.replace(/CharacterToReplace/, "NewCharacter");
Sorry, don't think I can really help you anymore.