def save_to_file fn, talk=true
    FileUtils.mkdir_p File.dirname(fn)
    if File.exist? fn
      unless BufferManager.ask_yes_or_no "File \"#{fn}\" exists. Overwrite?"
        info "Not overwriting #{fn}"
        return
      end
    end
    begin
      File.open(fn, "w") { |f| yield f }
      BufferManager.flash "Successfully wrote #{fn}." if talk
      true
    rescue SystemCallError, IOError => e
      m = "Error writing file: #{e.message}"
      info m
      BufferManager.flash m
      false
    end
  end
def save_to_file fn, talk=true
    FileUtils.mkdir_p File.dirname(fn)
    if File.exist? fn
      unless BufferManager.ask_yes_or_no "File \"#{fn}\" exists. Overwrite?"
        info "Not overwriting #{fn}"
        return
      end
    end
    begin
      File.open(fn, "w") { |f| yield f }
      BufferManager.flash "Successfully wrote #{fn}." if talk
      true
    rescue SystemCallError, IOError => e
      m = "Error writing file: #{e.message}"
      info m
      BufferManager.flash m
      false
    end
  end
helper functions