The code cannot work, as you remov items from the beginning. After processing half of the items your counter exceeds the count of the remaining items. Call remove on item(0), then the code should work.
clear() is the more elegant solution, though :-)