You get this exception because you are modifying (add / remove) a collection while you are iterating over it at the same time.
The standard iterators are written in a way to always throw these...