print out the content of a modified file
<p>I am having a problem with outputting a modified file in php, here is my code:</p>

<pre><code>&lt;?php
$content = file_get_contents("1.txt");
$items = explode("\n",$content);
$line = ""; 
foreach ($items as $item){
$values = explode(",",$item);
foreach ($values as &amp;$value){
    $key = array_search($value,$values);
    if ($key!=4){
        $line .= $value.",";
    }
    elseif ($value=="0"){
        $value="?";
        $line .= $value."\n";
    }
    else $line .= $value."\n";
}
}
$file = fopen("1.txt","w");
fwrite($file,$line);
fclose($file); 
?&gt;
</code></pre>

<p>The original content in 1.txt is </p>

<pre><code>1,1,1,1,1
2,2,2,2,0
</code></pre>

<p>The desired output is to be</p>

<pre><code>1,1,1,1,1
2,2,2,2,?
</code></pre>

<p>However, I got this when I run the script:</p>

<pre><code>1,1,1,1,1,2,2,2,2,?
,
</code></pre>

<p>What is the problem of my script? Thanks a lot!</p>
