in reply to Break the foreach loop on count on 50 and then insert a new foreach loop
so you basically want to apply some rules into iptables?
please just simply provide a small part of your original data e.g. list of ips
and a single line of the desired output