code: def _writeConnectivity(self, links, fileObject):
          
          for link in links:
              linkNum = link.linkNumber
              downLink = link.downstreamLinkID
              numUpLinks = link.numUpstreamLinks
              upLinks = ''
              for upLink in link.upstreamLinks:
                  upLinks = '{}{:>5}'.format(upLinks, str(upLink.upstreamLinkID))
  
              line = 'CONNECT{:>5}{:>5}{:>5}{}\n'.format(linkNum, downLink, numUpLinks, upLinks)
              fileObject.write(line)
          fileObject.write('\n')
docs: Write Connectivity Lines to File Method