Why am I getting infinite loops?

have you tried placing a break point (F9) and stepping through the execution?