How to show that $x \mapsto d(x,f(x))$ is continuous for a continuous $f$?

I'm busy with a topology course, but the following question has me somewhat stumped. The entire question is, let $(X,d)$ be a metric space and $f:X \rightarrow X$ be continuous. Show that $X \rightarrow R$, $x \mapsto d(x,f(x))$ is continuous.

I've tried proving it with the old-fashioned $\epsilon$-$\delta$ definition, but I quickly run out of options with that approach. If someone could give me a nudge in the right direction, it would be much appreciated!

-
Do you know that the composition of continuous functions is continuous? Now note that $f$ is continuous and $d(x,y)$ is continuous. – Asaf Karagila Jun 5 '12 at 21:07

The distance function $d: X\times X\longrightarrow \mathbb{R}^+ \cup \{0\}$ is continuous (this is an important fact on its own and you can prove it by using the triangle inequality). So is the function $i:X\longrightarrow X\times X$ defined by $i(x)=(x,f(x))$, because its projections are continuous. The composition of continuous functions is continuous.
Hint: $d(x,f(x)) \leq d(x,y) + d(y,f(y)) + d(f(y),f(x))$
Let $x_0\in X$. Let $\epsilon>0$. Then exist $\delta'>0$ with $d(f(x),f(x_0))\leq \epsilon/2$ if $d(x,x_0)<\delta'$. Let $\delta=\min \{\delta', \epsilon/2\}$. Suposse $d(x,x_0)<\delta$. By the triangular inequality $$0\leq d(x,f(x))\leq d(x,x_0)+d(x_0,f(x))\leq d(x,x_0)+d(x_0,f(x_0))+d(f(x),f(x_0))$$ and then $$-\epsilon<-d(x_0,f(x_0))\leq d(x,f(x))-d(x_0,f(x_0))\leq d(x,x_0)+d(f(x),f(x_0))\leq \epsilon/2+\epsilon/2=\epsilon.$$ Therefore $$|d(x,f(x))-d(x_0,f(x_0))|\leq \epsilon.$$