More generally, the shell has already told you what the problem is, if not where. It's a syntax error, and it has something to do with it coming across a newline where there shouldn't be one.
So start going through the script line by line, and search for syntax errors. Focus on things like improperly quoted strings and variables, improperly closed commands, and, as mentioned, missing semicolons.
Sometimes solving a bug simply requires the grunt work of slogging through the code.