A medical device for treating an aneurysm in a blood vessel includes a hollow shaft for insertion into the blood vessel, an exit port at a distal end of the shaft, a deflection element, and a position sensor. The hollow shaft encompasses a wire-insertion channel for leading a wire to be inserted into the aneurysm. The exit port is configured for exiting the wire from the wire-insertion channel and into the aneurysm. The deflection element is located adjacent to the exit port and configured to deflect the wire from the wire-insertion channel to the exit port. The position sensor, which is coupled to the distal end of the shaft, is configured to produce signals indicative of a position and orientation of the exit port in the blood vessel.