Instead of removing the elements, put the keys that you want to remove into a separate collection. At the end, traverse that other collection, removing the keys from your map.
Alternatively, use the Iterator interface instead of the for-each loop. This will enable you to use Iterator.remove() to remove elements while iterating.