I would strongly suggest to have these two loops strictly divided
from each other. That means:
1) Have one loop reading the whole file into the ArrayList.
2) Set up the iterator.
3) Have one loop processing the content of the ArrayList.
It really should be that easy.
Another approach (handy if you insist on having the strings from the
text file processed _and_ at the same time stored in the ArrayList)
would go like this:
Modify your loop such that the string read from the input file is
processed immediately and then only stored in the ArrayList; just
NEVER try to append something to an ArrayList which you want to
process out of this same ArrayList at the same time. That can't work.
I hope I made myself clear. If not, please ask again. I'm just too
plain tired to rewrite the loop now, so I leave that up to you.