def _writeheader(self, fileobj):
        offset = 0
        if not fileobj.simulateonly:
            with ignored(AttributeError, IOError):
                offset = fileobj.tell()

            self._header.tofile(fileobj)

            try:
                size = fileobj.tell() - offset
            except (AttributeError, IOError):
                size = len(str(self._header))
        else:
            size = len(str(self._header))

        return offset, size
dataset/ETHPy150Open spacetelescope/PyFITS/pyfits/hdu/base.py/_BaseHDU._writeheader/original