Dynamically Creating and Printing to Files

Hello,

If anyone could help me out with this, it would be greatly appreciated. I am trying to dynamically create files and print to them.
Here is the code I have to so far. thanks.

if (n < 5000 )
{
# do nothing
}
else
{
n = 0;
filenum++;
# out = ("out" filenum);
}

#Print out the xml to the standard output

printf(" <Account>\n") >> out; # out should be a variable and a new file should be created and output to when the name of this variable changes. thanks

Please be more specific. Your example makes no sense