BEGIN{ while(getline < "PRNameAnchor.out" >0){ id[$2]=$1 name[$1]=$2 }close("PRNameAnchor.out") Number=2 while(getline < table > 0) if(NF==Number && $0 !~/^#/){ if(id[$1]!="" && id[$2]!="") printf "%5d %5d\n", id[$1], id[$2] else{ printf "Check the %s\n", table exit } }close(table) }