code: def sanity_check_insdcio(handle, id_marker, fake_id_line):
      
      found_id = False
      found_end_marker = False
      for line in handle:
          line = line.strip()
          if not line:
              continue
          if line.startswith(id_marker):
              found_id = True
              break
          if line.startswith('//'):
              found_end_marker = True
              break
  
      handle.seek(0)
      # We found an ID, file looks good.
      if found_id:
          return handle
  
      # If there's no ID and no end marker, just give up.
      if not found_end_marker:
          return handle
  
      # If we found an end marker but no ID, fake one.
      new_handle = StringIO()
      new_handle.write("%s\n" % fake_id_line)
      new_handle.write(handle.read())
      new_handle.seek(0)
      return new_handle
docs: Sanity check for insdcio style files