Problem with agi script

Hello,
I have a script that checks for the clidid existence.
It worked fine with older version of asterisk (1.4.x)
Now after i switched to the latest(1.6.2.0) i get errors but the script works fine.
ERROR[13171]: utils.c:1126 ast_carefulwrite: write() returned error: Broken pipe

any ideas?

#!/usr/bin/php -q

<?php ob_implicit_flush(true); set_time_limit(6); $in = fopen("php://stdin","r"); $stdlog = fopen("/var/log/asterisk/my_agi.log", "w"); // toggle debugging output (more verbose) $debug = false; // Do function definitions before we start the main loop function read() { global $in, $debug, $stdlog; $input = str_replace("\n", "", fgets($in, 4096)); if ($debug) fputs($stdlog, "read: $input\n"); return $input; } function errlog($line) { global $err; echo "VERBOSE \"$line\"\n"; } function write($line) { global $debug, $stdlog; if ($debug) fputs($stdlog, "write: $line\n"); echo $line."\n"; } // parse agi headers into array while ($env=read()) { $s = split(": ",$env); $agi[str_replace("agi_","",$s[0])] = trim($s[1]); if (($env == "") || ($env == "\n")) { break; } } // main program // main program $cli = $agi[callerid]; $exten= $agi[extension]; //$pattern = "*\<[0-9]+\>*"; $pattern = "*[0-9]+*"; preg_match($pattern,$cli,$matches); $out = trim($matches[0], "<>"); errlog("Call from -$out-"); errlog("Call from -$cli-"); errlog("Call from -$matches[0]-"); If (!$out) { write ("SET CONTEXT from-sbc"); write ("EXEC GoTO from-sbc|s|1"); } Else { write ("SET CONTEXT planusers"); write ("EXEC GoTO $out,1"); } // clean up file handlers etc. fclose($in); fclose($stdlog); exit; ?>

when asterisk executes it it give errors:

-- Executing [s@pppp:2] AGI("SIP/sip.broadvoice.com.home-00000004", "checkcid.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/checkcid.agi

<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_request: checkcid.agi
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_channel: SIP/sip.broadvoice.com.home-00000004
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_language: en
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_type: SIP
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_uniqueid: 1263569251.6
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_version: 1.6.2.0
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_callerid: 1112223334
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_calleridname: Chicgozn01 IL
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_callingpres: 0
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_callingani2: 0
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_callington: 0
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_callingtns: 0
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_dnid: 2212223334
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_rdnis: unknown
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_context: pppp
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_extension: s
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_priority: 2
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_enhanced: 0.0
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_accountcode:
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> agi_threadid: -1222173808
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >>
<SIP/sip.broadvoice.com.home-00000004>AGI Rx << VERBOSE "Call from -1112223334-"
checkcid.agi: Call from -1112223334-
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> 200 result=1
[Jan 15 09:27:39] ERROR[13171]: utils.c:1126 ast_carefulwrite: write() returned error: Broken pipe
<SIP/sip.broadvoice.com.home-00000004>AGI Rx << VERBOSE "Call from -1112223334-"
checkcid.agi: Call from -1112223334-
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> 200 result=1
[Jan 15 09:27:39] ERROR[13171]: utils.c:1126 ast_carefulwrite: write() returned error: Broken pipe
<SIP/sip.broadvoice.com.home-00000004>AGI Rx << VERBOSE "Call from -1112223334-"
checkcid.agi: Call from -1112223334-
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> 200 result=1
[Jan 15 09:27:39] ERROR[13171]: utils.c:1126 ast_carefulwrite: write() returned error: Broken pipe
<SIP/sip.broadvoice.com.home-00000004>AGI Rx << SET CONTEXT planusers
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> 200 result=0
[Jan 15 09:27:39] ERROR[13171]: utils.c:1126 ast_carefulwrite: write() returned error: Broken pipe
<SIP/sip.broadvoice.com.home-00000004>AGI Rx << EXEC GoTO 1112223334,1
– AGI Script Executing Application: (GoTO) Options: (1112223334,1)
– Goto (planusers,1112223334,1)
<SIP/sip.broadvoice.com.home-00000004>AGI Tx >> 200 result=0
[Jan 15 09:27:39] ERROR[13171]: utils.c:1126 ast_carefulwrite: write() returned error: Broken pipe
– <SIP/sip.broadvoice.com.home-00000004>AGI Script checkcid.agi completed, returning 0