code: def write_file(self, file, verbose=False):
          
          dat = self.get_midi_data()
          try:
              f = open(file, 'wb')
          except:
              print "Couldn't open '%s' for writing." % file
              return False
          try:
              f.write(dat)
          except:
              print 'An error occured while writing data to %s.' % file
              return False
          f.close()
          if verbose:
              print 'Written %d bytes to %s.' % (len(dat), file)
          return True
docs: Collect the data from get_midi_data and write to file.