I have to separate working one from non working, but also with all the line.
you can just loop through the file, and write the status to corresponding text files
sed 's/;/ /' file | while read ip other
do
nc -zw3 $ip 80 && echo "$line" >> opened.txt || echo "$line" >> closed.txt
done
If you want to keep the IP; otherstuff
format, you can use this one instead
while read line
do
ip=$(sed 's/;.*//' <<<"$line")
nc -zw3 $ip 80 && echo "$line" >> opened.txt || echo "$line" >> closed.txt
done < file