It fails to compare the token named 'key' in the if-else if condition inside the nested while. As a result, code inside this if-else branch is never executed. Can anybody let me know why is that so? Maybe its something trivial that i'm missing..