'Save a readline history file.'

def write_history_file(self, filename=None):

    if (filename is None):
        filename = self.history_filename
    fp = open(filename, u'wb')
    for line in self.history[(- self.history_length):]:
        fp.write(ensure_str(line.get_line_text()))
        fp.write(u'\n')
    fp.close()
