So the text file is getting created at the same time that the first page is displaying the form? Hopefully before? If so, then all you have to do is this on the first page:
<?php
// determine name of text file (maybe random, maybe sequential, whatever)
// text file name should be in a variable... maybe $textfilename or something
// create text file
// display form like this:
print "<form action=\"page2.php\" method=post>";
print "<input type=hidden name=tfn value=\"$textfilename\">";
// display the rest of the form
print "</form>";
?>
Then on the next page, you will have a variable (I called it tfn, you can call it whatever you like). That variable will contain the name of the text file that was created on the previous page.