Is there an error you're getting? I don't see any particular problem in the code.
Normally, you'd want to have a database do this job for you. It is much simpler than having to read/write from files.
For example, with a DB it is as simple as:
$result = $Db->Query("DELETE FROM `table` WHERE `column` = '".mysql_real_escape_string($_GET["file"])
."' LIMIT 1";
The database then does basically what you are doing with the files, on the disk or memory depending on the storage type being used. Databases are very efficient at this though by design.
Your code is very good for file updates as it is very memory efficient. If you are working with small files, you could save time by doing something like:
// retrieve file into a string
$txt = file_get_contents('toApprove.txt');
// replace the line with $_GET["file"], assuming line break is \n
$txt = str_replace(trim($_GET["file"])."\n", '', $txt);
// write the string back to the file
file_put_contents('toApprove.txt', $txt);
or
// retrieve the file into an array where each line is a value
$Array = file('toApprove.txt');
// assuming unique values, lets remove the Array key with value $_GET["file"]
unset($Array[array_search(trim($_GET["file"]), $Array)]);
// explode the array into string with line breaks seperation and put everthing back in the file
file_put_contents('toApprove.txt', implode("\n", $Array));
It is much simpler, however, is memory intensive if you have a large file since you will be saving the whole file contents to a variable, $txt (PHP memory).
file_get_contents() should be more efficient than using fopen() and fgets() for smaller files.. it certainly is more convenient.
file_put_contents() is only supported on PHP5, so you can test for it and your system and create the function if it doesn't exist:
if (!file_exists('file_put_contents')) {
// create a simple user function to emulate PHP5's file_put_contents()
function file_put_contents($file, $contents) {
fwrite($fp = fopen($file), $contents, strlen($contents));
fclose($fp);
}
}
that should work for basic use.