The original script is working fine if you don't mind to get spammed by emails every time someone visited your profile.
Anyway here is my version of this script for those who wish another way than getting emails.
Obviously you need to change the path where this script will save the logfile.
Also I formated a bit the output so it will also include the date when you got a visitor.
The HTML part is the same as the OP. Nothing changed there.
You may need to create an empty logfile if the script doesn't work straight out of the box the first time.
<?php
$ip = getenv(REMOTE_ADDR);
$avi = $_GET['AviName'];
$datenow = date('Y-m-d H:i:s');
$file = '/path/to/the/logfile';
$message = "[".$datenow."] -- ".$avi." visited your homepage with IP: ".$ip."\n";
file_put_contents($file, $message, FILE_APPEND | LOCK_EX);
?>