Now that's a useful error message!
Line 18 is:
js code:
line = line.replace('alias "serverinfo [', '');
This is just weird. I tried this myself and indeed, ReadLineFromFile returns false, meaning that the requested line number exceeds the amount of lines in the file. Apparently, the empty lines were omitted from the line array when doing the split(). However, when I replaced the regular expression by a normal string, it correctly produced an array with empty strings for empty lines! It appears that this is an inconsistency in the JScript implementation itself
(thanks for that, Microsoft), so the only way to get around this is by using a string as separator or by writing your own split() method. In this case, using a string will do.
Just replace line 5 with:
js code:
var FileContents = s.split("\n");
and it should work. In order to prevent further problems with this, you could add some error handling in case ReadLineFromFile returns false:
js code:
var line = ReadLineFromFile("C:\\Program Files\\AssaultCube_v1.1.0.3\\config\\saved.cfg", 255, false);
if( line === false ) return ''; // line not found, die silently
line = line.replace('alias "serverinfo" [', '');
// ...