Andreas shot first, but I still encourage everybody to have a look at the lemma on p.263 of R. Alperin,Locally compact groups acting on trees and property $T$. Monatsh. Math. 93 (1982), no. 4, 261–265: any homomorphism from a locally compact group to $\mathbb{Z}$, is continuous. This answers Florent's question.