Don't modify a list you're iterating over. This results in undefined behaviour and might not work as expected.