'Join the footnotes from the bottom of the file and put them in their
former places.  First, remove the footnotes from the bottom of the
input file, outputting them to a temporary file. This creates two new
files, one without footnotes, and one of just footnotes. Open both
these files to read. When a marker is found in the main file, find the
corresponding marker in the footnote file. Output the mix of body and
footnotes to a third file.'

def join_footnotes(self):

    if (not self.__found_a_footnote):
        return
    self.__write_to2 = better_mktemp()
    self.__state = 'body'
    self.__get_footnotes()
    self.__join_from_temp()
    copy_obj = copy.Copy(bug_handler=self.__bug_handler)
    if self.__copy:
        copy_obj.copy_file(self.__write_to2, 'footnote_joined.data')
    copy_obj.rename(self.__write_to2, self.__file)
    os.remove(self.__write_to2)
    os.remove(self.__footnote_holder)
