Might I suggest some other things? For example, insertline, to insert a line before line number (line)?
Code: function file_insertline(path,line,content){
file = file_read(path);
lines = file.replace(/(\r\n|\r|\n)/g, '\n').split('\n');
lines.splice(line,0,content)
file = lines.join("\n");
file_create(path,file);
}
And of course, the reverse that lets you delete a specific line:
Code: function file_deleteline(path,line){
file = file_read(path);
lines = file.replace(/(\r\n|\r|\n)/g, '\n').split('\n');
lines.splice(line,1)
file = lines.join("\n");
file_create(path,file);
}
And a function to append a line?
Code: function file_appendline(path,content){
file = file_read(path);
lines = file.replace(/(\r\n|\r|\n)/g, '\n').split('\n');
lines = lines.concat(content)
file = lines.join("\n");
file_create(path,file);
}
(be aware that I didn't get to test these yet)