def writestr(self, str):
        """ Write string to output file descriptor.
        All output operations go through this function.
        We keep the current file position also here"""

        # update current file position
        self._fpos += len(str)
        for x in range(0, len(str)):
            if str[x] == '\n':
                self._fpos += LF_EXTRA
        try:
            self._ofs.write(str)
        except IOError, e:
            print e
            return -1

        return 0
 Write string to output file descriptor.
        All output operations go through this function.
        We keep the current file position also here
recipes/Python/189858_Python_text_to_pdf_converter/recipe-189858.py