There's an extra close brace on the line before the "Out of the loop" line; that messes up everything from that point on.
If you're using Notepad or something along those lines to edit your code: this is the kind of thing that any decent programmers editor would point out to you as you type.