SQL*Plus does not execute SQL scripts that SQL Developer does
Remove the empty lines.
In sqlplus an empty line means stop previous statement and start a new one.
or you can set blank lines:
set sqlbl on
Alternatively you can use "Ctrl F7" in sqldeveloper to format your script. I had a similar issue and tried removing blanks etc. but I was obviously missing something. Found the Ctrl F7 function and the script worked.