Your " loop() " function is inside " setup() " function.
Try adding a brace to close your setup() function just after the " for " loop.
One question: why do you have a right brace " } " after the first if condition in your loop() function?
I suggest to comment it out.