def dump_to_json(self, output_file): filehandle = open(output_file, 'a') for tweet in self.collection.get_iterator(): filehandle.write(json_util.dumps(tweet)+'\n') filehandle.close()