). Therefore, I am just guessing: It seems you are overwriting the output file for each iteration of the $ii. The output you mention is the output of the last iteration. You probably do not want to iterate over all the arrays, for one of them you rather need to use its
value. I do not understand the code enough to tell you which one.