title: Outputting Traversal of a BST to a File
body: <p>I've made a program that does things with a binary serach tree, and I have a method that prints the post-order traversal of it.    </p>
  
  <pre><code>public static void postOrderTrav(TreeNode node){
      if(node != null){
          postOrderTrav(node.getLeft());
          postOrderTrav(node.getRight());
          System.out.print(node.getVal() + " ");
      }
  }
  </code></pre>
  
  <p>However, I also want to print the post-order traversal to a <em>file</em> as well. How do I do this, in this method that uses recursion? I've tried putting the call to the writeToFile method in various places, but they always write out only one number...</p>