Unique Hit counter not working properly
I have a unique hit counter script, 

    <?php
    $filename = "hits.txt";
    
    $file = file($filename);
    $file = array_unique($file);
    $hits = count($file);
    echo $hits;
    
    $fd = fopen ($filename , "r");
    $fstring = fread ($fd , filesize ($filename));
    fclose($fd);
    $fd = fopen ($filename , "w");
    $fcounted = $fstring."\n".getenv("REMOTE_ADDR");
    $fout= fwrite ($fd , $fcounted );
    fclose($fd);
    ?>
It stores the IP's in a text file. The problem im having is that it counts each ip three times, instead of one. Take a look at my site http://freexboxlivecodes.cz.cc and you'll see, its below the second paragraph. Anyone know how to fix this?
Unique Hit counter not working properly
===

I have a unique hit counter script, 

    <?php
    $filename = "hits.txt";
    
    $file = file($filename);
    $file = array_unique($file);
    $hits = count($file);
    echo $hits;
    
    $fd = fopen ($filename , "r");
    $fstring = fread ($fd , filesize ($filename));
    fclose($fd);
    $fd = fopen ($filename , "w");
    $fcounted = $fstring."\n".getenv("REMOTE_ADDR");
    $fout= fwrite ($fd , $fcounted );
    fclose($fd);
    ?>
It stores the IP's in a text file. The problem im having is that it counts each ip three times, instead of one. Take a look at my site http://freexboxlivecodes.cz.cc and you'll see, its below the second paragraph. Anyone know how to fix this?