We reexamine the two-dimensional linear O(2) model (φ4 theory) in the framework of the nonperturbative renormalization-group. From the flow equations obtained in the derivative expansion to second order and with optimization of the infrared regulator, we find a transition between a high-temperature (disordered) phase and a low-temperature phase displaying a line of fixed points and algebraic order. We obtain a picture in agreement with the standard theory of the Kosterlitz-Thouless (KT) transition and reproduce the universal features of the transition. In particular, we find the anomalous dimension η(T(KT))≃0.24 and the stiffness jump ρ(s)(T(KT)(-))≃0.64 at the transition temperature T(KT), in very good agreement with the exact results η(T(KT))=1/4 and ρ(s)(T(KT)(-))=2/π, as well as an essential singularity of the correlation length in the high-temperature phase as T→T(KT).