I didn't even spot it -- the resolution is poor enough that I could probably blame that, but it's more likely I just didn't see it because I assumed it wasn't there. Probably would have seen it when I looked closer at the code if you were still having problems. Glad you found the problem and thanks for letting us know what it was.
Oh, BTW logic errors like this are very easy to make and very easy to overlook once made. Many compilers will give warnings when you make the more common logic errors like this. Did your compiler throw any warnings?
There are also lint checkers (a program that examines the code specifically for logic/format irregularities) that are very good at pointing out these kinds of mistakes. You might check into one of them.