Hello again,
as far as I see, you have not only to write a new file, but also to put specific information in that. Did you have a look on
RE: CGI Question, which was a reply to your former post?
You are facing the task, to manipulate the output. So you can read a file and change the contained data or compose the file from , let's say 'static' elements and those you are putting in by runtime.(just like using templates)
Have a nice day
All decision is left to your taste