Try with this:
<?php
    $f = "data.dat";
    $term = "this";
    $arr = file($f);
    foreach ($arr as $key=> $line) {
        //removing the line
        if(stristr($line,$term)!== false){unset($arr[$key]);break;}
    }
    //reindexing array
    $arr = array_values($arr);
    //writing to file
    file_put_contents($f, implode($arr));
?>
1
solved how to delete a specific line from a file starting a string in php