As you can see, they are basically the same code, just with different things in the print and in different scripts. However, one for whatever reason shows this error:
The error must be because of an issue somewhere else in the script where you forgot to close the if/loop/function etc with an end as the images you provided look fine.