in reply to capturing and parsing multiline output

This is to some extent peripheral to your question, but if you have a version of 'dig' that supports the +short option, you'll get a simpler list of data to parse.

For example:

C:\dig>dig www.cnnsi.com +short 64.236.29.106 64.236.29.107 157.166.255.22 157.166.255.23 64.236.22.106 64.236.22.107 C:\dig>nslookup www.cnnsi.com Server: ltc1usdc1.us.ceridian.hrs Address: 10.2.69.11 Non-authoritative answer: Name: www.cnnsi.com Addresses: 64.236.29.106, 64.236.29.107, 157.166.255.22, 157.166.255. +23 64.236.22.106, 64.236.22.107