prova così

$xyz = array("\r\n", "\n", "\r");
$replace = '';

$str = $var,"l'utente ".$utente." ha effettuato l'accesso il giorno ".$data." alle ore ".$ora." ip ".$ip);
$newstr = str_replace($xyz, $replace, $str);

fwrite($newstr);