Moved some of the debug code around

This fixes a bug when the end of the program is reached
Bugfix

Previously the interpreter assumed every loop would always be entered at
least once. This is a false assumption.