You could also use the square-bracket quote mechanism, and then open the result in a script editor window. Note the backslash and the open or close square bracket are not part of the saved text, and the embedded quotes need no escaping.
filename = Save Text File(
"$temp/DeleteMe.JSL",
// this is the opening square-bracket quote
"\[
// comment 1
write("these quotes need no special treatment
and the newline works too
"); // comment 2
//comment 3
]\" // this is the closing square-bracket quote
);
editor = Open( filename, "script" ); // "script" might be needed if the extension is missing
Script Editor Window with contents of file
Craige