problem with passthrough escape to a file as an output port

I'm am encountering a problem using passthough escape.
My application needs to send printer commands directly to
the printer bypassing the driver (for acceleration & memory consumption reasons).
I am using the passthrough escape (can't do a "writeprinter" because I need
my data to be added to the original printjob)

This works fine when printing directly to the printer, but when I change the
printer port to a file (using the setprinter function)
The data is not "passthrough'ing" to the file, even so the escape
function seems to be working.

I need to print to file because I want a printjob that contains many pages
each with a different number of copies.

My algorithim works like this

1. redirect the printer to file "a" (using setprinter)
2. set printer copies (using setprinter)
3. begindoc
4. use canvas printing methods
5. add my passthrough special additions
6. enddoc
7. append the "a" file to file "b"
8. loop to stage 1 until all pages are done
9. sending the "b" file to the orignial printer port (using openprinter,
startdocprinter, writeprinter, enddocprinter & closeprinter)

any suggestions how to make the passthrough esacpe work with a file as an
output port, or alternativly any other method to print multiple pages with
multiple copies as one print job,   welcome

Thank you
Tzahi