it desn't work because you tell the script to search for "cool\n" (cool with a linebreak). And second, str_replace is CaSe SeNsItIvE, so if the word "cool" is spelled "Cool", it wont be replaced. To get around that, use regular expressions instead.
To really make sure that all "cool" words will be replaced, simply change...
$somecontent = $_GET['data'] . "\n";
to this;
$somecontent = $_GET['data'];
And change this...
$file_data = str_replace($somecontent, "", $file_data);
To this
$file_data = preg_replace("/$somecontent/is", "", $file_data);