in reply to Creating a new file each iteration

If the above code is inside your loop, changing open (TEXT, ">>cell_.txt")
to open (TEXT, ">cell_$somevariable.txt") should do it.