For the uninitiated, the answer was (as nicely demonstrated by Kalai Selvan T's example) that the output file was being recreated every time savePreOrder() was called (i.e. for each node in the tree). The resulting output file would simply have contained the data for a single tree node.
I'd better be right about that now!
Jules