PHP Redirect Script

Hello Unix.com,

I badly need to get rid of drones that access my website. I'm using a hits php script that logs every ip that visits my index.php. Looks like this:

<?php
$IP = getenv("REMOTE_ADDR");
$day = date('l jS \of F Y h:i:s A');
$fout = fopen("hits.txt", "a");
fputs($fout, "$IP");
fclose($fout);
?>

How can I make an addon to act like this: to search the "hits.txt" file and if an ip is in the list for 3 times to redirect him to lets say about:blank or google or any other and the visit "attempt" not to appear in the "hits.txt" log.

Thanks in advance,
Galford. D. Weller