Compare two string in a while loop

You have three variables named motInter. One is global scope and the others have local scope inside your while loops. Inside your while loops you change the value of the local variable and in your loop test you compare the global variable. Remove the local variable declarations and things should improve.