basterà impostare il secondo parametro di fopen su w.
Quindi
Codice PHP:
$var=fopen("testo-auto.txt","w"); 
fwrite($var"$testo");