If you want to ftruncate but keep the end:<?php function ftruncatestart($filename,$maxfilesize){ $size=filesize($filename); if ($size<$maxfilesize*1.0) return; $maxfilesize=$maxfilesize*0.5; $fh=fopen($filename,"r+"); $start=ftell($fh); fseek($fh,-$maxfilesize,SEEK_END); $drop=fgets($fh); $offset=ftell($fh); for ($x=0;$x<$maxfilesize;$x++){ fseek($fh,$x+$offset); $c=fgetc($fh); fseek($fh,$x); fwrite($fh,$c); } ftruncate($fh,$maxfilesize-strlen($drop)); fclose($fh); }?>It will not just cut it but search for a newline so you avoid corrupting your csv or logfiles. But I don't know if you will stress the reading head of your drive. ;)