Cristina is correct. Sometimes, when copying from the History palette and pasting in Notepad, it seems to not be correctly indented. The commented line (with the #) can be anywhere, but the rest of the actual command has to be correctly indented.
I am not sure if you have figured out the trick but when you select all the lines, if you press Tab, it will add 4 spaces. If you press Shift-Tab, it will remove 4 spaces to all the selected lines.
Maybe that would help?
To your example where the SOP points to a line that you have not touched, sometimes, it has to do with the previous line, so always check that too: if the previous line is indented wrong, or is missing a closing bracket, the script won’t notice an error until the “next” command, which might be one you had not touched.