Look at line 28 and imagine that b[pos] points to a list of 10 items when you get there. The first time through the loop, the code points b[pos] to the SECOND item, effectively throwing away the first time. The next time through it throws away the next item. By the time the loop ends, all 10 items have been thrown away.
What I think you should do is add the item to the beginning of the list instead of the end, It's much easier that way: