regardless of the typos I posted here, why dosent this work right.

My real program is much more complex, this is just the part that I have narrowed down the problem to.