lusun,
What you describe is called continuations, it is a CS term and will most likely warp your brain the first few times you read it (at least it did me). Here is some information on continuations:
Continuations in PHP
If that melts your mind or sounds too hard to implement you have a couple of routes you can go.
1) Sessions. This is probably the easiest. You can load the questions into an array, then store them in the session. as the user answers the questions, increment a counter and return the question at that position in the questions array. All the while store the answers in an array (again in the session) so it persists. When out of questions, then write your file.
2) DB. This is similar to the sessions, except instead of using the PHP session file storage, you load the questions into a database, you then have a answers db that links back to the Question, by Id. This way, you can keep all the user's answers in one place and data-mine it later a lot easier than a bunch of files. As someone else mentioned you would have to keep a pointer to which question you are on. This could again be sessions, you could write it in a cookie, or you could simply pass it around in a hidden input element.
3) This would be the most fun and give you the ability to go back and forth in the questions. You could write out the questions to the HTML file perhaps in a hidden div element. Then use JS to parse them into an array structure on new line or whatever the break is. Then have a button on the screen that instead of submitting the form, it checks to see if there are any more questions. If so, it replaces the text on the screen with the new question. storing the answer in a another array structure. When you are out of questions, then it takes the answers, joins them together with new lines. Puts it into a hidden input or text area and submits to the server. Then bam, you have the entire contents of the file ready to just write out somewhere.
Hope some of this helps,
Mike