Try kixref.exe, run it like this:

kixref script.kix script.out

then notepad script.out ...

In there you'll see line numbers, and next to that - a "level" number that shows you how "deep" you are within your nested IF's and WHILE's. Look for breaks in the sequence ...

-Shawn