Oh, I did pretty much the same two weeks ago. Funniest thing was that I was even thinking that it could be this problem, and I checked the exact place in the code. And still didn't see it. Needed to take a break before finding it...
Well, first off, the fact that the code printed a bunch of newlines where it should have been printing other characters made me suspect another part of the code (whose output was shifted up the screen by all the newlines).
Once I eliminated that, I didn't even suspect that I'd written "=" for "==", even after it became obvious that code that should execute conditionally was executing unconditionally. So I reordered the code to put the "else" case first, and in doing so introduced another bug, which involved ">" instead of ">=", and also demonstrated that newlines were still being generated where they shouldn't be (though not everywhere). I think the fact that I had to add an "=" to solve that bug clued me in to what the original bug was.
The scary thing is that, had I not introduced the second bug, not only would I not have gotten the clue I needed for the first bug in fixing it, but the first bug would have been masked (but not taken care of) by the reordering I did.