changed script to do hostname ip extraction and ip lookup in one loop