The append method will invalidate the iterator, so we cannot call the erase() method with the old iterator.