So when you set a breakpoint at the for loop after
pos = lstItems.GetHeadPosition();
that is not hit and execution is not stopped? That would be weird. I assume that you are using a debug build with all optimisations disabled. Otherwise, the compiler may optimise away the following lines because they effectively do nothing. To check this you can insert a TRACE statement inside the loop printing nElement.