Thanks, Wysota. However, I'm a bit unclear about what you mean. I thought I used atEnd() but in my example it does not work. The for loop still messes up.