A dental handpiece for the endodontic treatment of a root canal, comprising(i) a chuck for attaching and holding an endodontic file;(ii) an electric motor having a shaft for driving the endodontic file;(iii) a control unit for controlling the motor, which receives a stream of input data;characterized in that while monitoring the stream of input data, the control unit determines the current absorbed by the electric motor, and controls the motor so that the file alternates the direction of rotation at a frequency of from 1 to 20 Hz between a first direction and a second direction opposite to the first direction, and whereby the control unit controls the electric motor so that the file continuously rotates in the second direction when the monitored data fulfils a predetermined torque threshold condition during rotation in the first direction.