in reply to still can't create a file using a variable

Try adding some error checking to your code:
$filename = $timestamp.".txt"; print $filename; sleep 5; open (TEMPFILE, ">$filename") or die "error, can't create $filename : +$!";
This should tell you while the file create failed.