deleteLine-Method of vcCompactLineSet is not working as expected

Hello everyone,
I am trying to create custom Lines using a Python Script Behaviour. For this I am using a Geometry Feature with a vcCompactLineSet inside. This part is working without issue. Now I want to remove the existing Lines from the vcCompactLineSet when I rerun the script, this does not work.
Currently this is my testing Code:

comp = getComponent()
      line_geo = comp.findFeature("Line")
      line_geo.Geometry.clear()
      line_set = line_geo.Geometry.createGeometrySet(VC_COMPACTLINESET)
      line_set.addLine([vcVector.new(0,0,0), vcVector.new(0,0,length)])
      line_set.LineWidth = 1.0
      # try to delete just created line
      for line_index in range(0, line_set.LineCount):
        line_set.deleteLine(line_index)
      # check if lines still exist
      for line in line_set.Lines:
        print(line)
      line_geo.rebuild()
      app.render()

Basically I create a new Line which I then try to delete again from the vcCompactLineSet that was created. I would expect the print command to then print nothing since the vcCompactLineSet was empty before. Instead I get the printout of the Line I just created. Does anyone know what I could be doing wrong. All help is appreciated.

Kind regards

fystro