def save doc, output, &data_iterator
    
      if output.respond_to?(:write)
        @out_stream = output
      else
        @out_stream = open(output, "w")
      end
    
      data_iterator.call(doc)
      
    end
def save doc, output, &data_iterator
    
      if output.respond_to?(:write)
        @out_stream = output
      else
        @out_stream = open(output, "w")
      end
    
      data_iterator.call(doc)
      
    end
output can be a String (as a file name) or an output stream
 examples:
     engine.save doc, "my_doc.txt"  do |spreadsheet|
        ...
     end

     engine.save doc, $stdout  do |spreadsheet|
        ...
     end