How do I remove edges and join them?

How do I remove edges and join them?
I would appreciate it if you could let me know the problem.
Please correct it.

import rhinoscriptsyntax as rs

def create_fillet_rectangle():
    # Define the points of the rectangle
    pointA = rs.AddPoint(30, 0, 0)
    pointB = rs.AddPoint(60, 73, 0)
    pointC = rs.AddPoint(-60, 73, 0)
    pointD = rs.AddPoint(-30, 0, 0)

    # Add the polyline
    pt = [pointA, pointB, pointC, pointD]
    profile1 = rs.AddPolyline(pt)

    # Mirror the polyline
    profile2 = rs.MirrorObject(profile1, (0, 0, 0), (1, 0, 0), True)
    
    # Join the curves
    joincrv1 = rs.JoinCurves([profile1, profile2])

    if not joincrv1:
        print("Failed to join curves.")
        return

    # Set the fillet radius
    fillet_radius = 20

    # Explode the joined curve into segments
    segments = rs.ExplodeCurves(joincrv1[0])

    if not segments or len(segments) < 2:
        print("Failed to explode joined curve.")
        return

    # Apply fillets between each pair of segments
    fillets = []
    for i in range(len(segments)):
        seg1 = segments[i]
        seg2 = segments[(i + 1) % len(segments)]
        fillet = rs.AddFilletCurve(seg1, seg2, fillet_radius)
        if fillet:
            fillets.append(fillet)
    
    if fillets:
        # Delete the original segments
        rs.DeleteObjects(segments)
        rs.DeleteObject(joincrv1)
        
        # Join the filleted curves
        fillet_ids = [seg1] + fillets
        for i in range(len(fillets) - 1):
            fillet_ids.append(fillets[i].Split(0.5)[1])
        
        joined_fillet = rs.JoinCurves(fillet_ids)
        if joined_fillet:
            print("Fillets applied and curves joined successfully.")
        else:
            print("Failed to join filleted curves.")
    else:
        print("Failed to create fillets.")

if __name__ == "__main__":
    create_fillet_rectangle()