Newbie error code

and for where the loop ends i have no answer for that lol.

A clue. After Auto Format the last line of code in the program should start on the left margin of the editor and the last character in that line (comments aside) should be a closing curly bracket which marks the end of the last function in the program.