write to file instead of rendering to screen

Radiant gurus please help! I know this should be for the Radiant
mailing list, but very low activity there.

I am trying to create functionality to write the HTML(page(s)) to a
file instead of rendering to screen. I want to capture the html of a
new or modified page (and FTP it ultimately). I know my code needs to
be somewhere in the show_page, process_page area but I don't know
exactly where it should go or what the code would look like.

use case:
user creates or modifies a page in radiant.
user presses button 'write to file'
the page html is then captured and written to file before rendering to
screen.

please help