Program around this while loop not working as expected
Instead of setting i=1, you could use a 'break' command to break out of the while loop.  That way you don't need 'i' at all, you can just do 'while(true)'