Let $F \subset R$ be a nonempty closed set and define $g(x) = \inf \{ | x - a | : a \in F \}$. Show that g is continuous on $R$.
I follow a solution, and this is its approach to prove the statement. First, it proves $\forall x \in R$, there exists a number $a_x \in F$ st, $g(x) = | x - a_x |$, and uses the result to state that for a constant $x_0$ and its corresponding $a_0$, $$ | g(x) - g(x_0) | = \inf \{| |x - a| - |x_0 - a_0| | : \forall a \in F \} \space (1) $$
By triangle inequality, it is straightforward to prove, $$|| x - a | - |x_0 - a_0|| \le |x - x_0 | + |a - a_0|$$
The rest of the proof is obvious following definition of continuity.
I got stuck in the equation (1), though I obtained the equation, $$ | g(x) - g(x_0) | = |inf \{ | x - a | : a \in F\} - |x_0 - a_0| |$$
How to prove (1)? I also appreciate if you provide any other solution.