Move end point of curve to make it close [Rhino, Python]

Hello,
Can you explain why replace is necessary? Is there a way to do it by just drawing a new curve from the geometry?