Problem resolved thanks to Boerema plus a few little tweaks of my own.
Basically I just changed the delete part till after the form was processed, sine when the form is displayed it was deleting or creating without submission.
So...
In the form itself the code is...
$filename = '/full/path/to/tempfile/sent.txt';
if (file_exists($filename)) { //
$recipients = 'number1emailaddress@test.com';
} else {
$recipients = 'number2emailaddress@test.com';
}
Then after the form has processed
$filename = '/path/to/your/tempfile/sent/sent.txt';
if (file_exists($filename)) {
unlink($filename); //delete the file
} else {
fopen($filename, 'w') or die('Cannot open file: '.$filename); //implicitly creates file
}
This way the file is only deleted/created on an actual submission, which works perfectly
Many thanks Boerema