Yep, that's how bash does things.
The reason it bombs on the next line is that even though the recommended fix is on the line I said it's on, there is technically no error on that line. It's just that bash expects certain things _after_ what's on that line, and by the time it reads the next line, it hasn't found them. If that makes any sense.
Incidentally, part of where you put the fix is a matter of style. Here's the style you use:
Code:
for A in blah blah; do
echo $A
done
You could just as easily do this:
Code:
for A in blah blah
do
echo $A
done
Note the missing semicolon. In the first example, the semicolon alerts bash to where the "blah blah" ends; in the second example, the end of line does the same thing. In your situation, bash gets to the y0 line, thinks it's still evaluating the "blah blah", and croaks.
Incidentally, you get the same two choices of style in the previous "while" line. Between the two style examples above in the reply you're reading now, I chose the first one when I wrote my original answer, because that made the style of your "for" statement the same as the style in your "while" statement.
(I use the other style myself, because that makes the "do" line up with the "done", and for me that makes things more readable. This is a
religious issue.)
Hope this helps.