Whois Arin和php

I have a problem with php and whois.arin.net

$whois="whois.arin.net";
$ip="xx.xx.xx.xx";
$sk=fsockopen($whois, 43, $errno, $errstr, 30) or die('Connessione impossibile');
fputs ($sk, $ip."
") or die('Request impossibile');
while (!feof($sk)) {
  $info.= fgets ($sk, 2048);
}

$i=explode("
",$info);
foreach($i as $val){
  $descr=explode("
",$val);
  echo $descr[0];
}

The error that appears is

ARIN WHOIS data and services are subject to the Terms of Use

Query terms are ambiguous. The query is assumed to be: n xx-xx-xx-xx

What is the problem?

A very simple PHP whois function that supports ARIN would look like this:

function whois($domain, $server) {

    // format input for the specific server
    if($server == 'whois.arin.net') {
        $domain = "n + $domain";
    }

    // connect and send whois query
    $connection = fsockopen($server, 43, $errno, $errstr, 30);
    $request = fputs($connection, $domain . "
");

    if(!$connection OR !$request){
       return "Error $errno: $errstr.";
    }

    // get the whois data
    $data = '';
    while(!feof($connection)){
            $data .= fgets($connection);
    }

    fclose($connection);
    return trim($data);
}

Then you can call the function like so:

echo whois('8.8.8.8', 'whois.arin.net');