in reply to IP-Stored in file not working

I am not able to run your code, because the subs ReadFile and WriteFile are not provided (see Short, Self Contained, Correct Example). 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 $array[$ii] value. I do not understand the code enough to tell you which one.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ