You're going about this the wrong way. You can create the file and serve it to them, and delete it in one step.
<?php
$file_contents = 'these are the contents of your file';
$random_filename = md5(time()+rand(0,10000)).'.txt';
$public_directory = '/www';
$the_file = $public_directory.'/'.$random_filename;
file_put_contents($the_file, $file_contents);
echo file_get_contents($the_file);
unlink($the_file);
?>
If you do it that way, the files get deleted immediately after the user sees them. Of course, this means that the file need not exist in the first place. So you could shorten the code to this:
<?php
$file_contents = 'these are the contents of your file';
echo $file_contents;
?>
It all depends on where you're getting the content you want to show them. If it's from a file, try:
<?php
$file_contents = file_get_contents($filename_or_url);
echo $file_contents;
?>
As for deleting files automatically, just setup a cron job that runs every 10 seconds, and deletes all the files in your temp folder that where filemtime($filename) is greater than 5 minutes' worth of seconds.