Uniform continuity on two subsets of $\mathbb R$ implies uniform continuity on $\mathbb R$ 
Suppose $a$ is a fixed real number and $f$ is a function which is uniformly continuous on both the intervals $(-\infty, a]$ and $[a,\infty)$. Show that f is uniformly continuous on $(-\infty,\infty)$.

If $f$ is uniformly continuous then $\forall \epsilon >0$ $ \exists \delta $ such that $\lvert x-x_0 \rvert < \delta \implies \lvert f(x)-f(x_0) \rvert < \epsilon$
I want to use contradiction and say assume $f$ is not uniformly continuous on $(-\infty,\infty)$ so that $\lvert f(x)-f(x_0) \rvert \ge \epsilon$
So I would need to show that the sum of $f$ on $(-\infty, a] $ and $[a,\infty)$ is less than $\epsilon$?
Can I use an inequality somehow to connect $\lvert f(x)-f(x_0) \rvert < \epsilon$ on $(-\infty,a] $and $[a,\infty)$ and $\lvert f(x)-f(x_0) \rvert \ge \epsilon$ on $(-\infty,\infty)$
 A: Choose a $\delta_1,\delta_2>0$ so that $x,y\in(-\infty,a], |x-y|<\delta_1\implies |f(x)-f(y)|<\epsilon/2$ and $x,y\in[a,\infty),|x-y|<\delta_2\implies |f(x)-f(y)|<\epsilon/2$. Let $\delta<\min\{\delta_1,\delta_2\}$. 
Now, let $x<a$ and $y>a$ with $|x-y|<\delta$.  Since $|x-a|,|y-a|<\delta$
$$|f(x)-f(y)|\le |f(x)-f(a)|+|f(a)-f(y)|<\epsilon/2+\epsilon/2=\epsilon.$$
A: This answer is using contradiction.
First note that $f$ is left-continuous at $a$ as a consequence of the fact that $f$ is uniformly continuous at $(-\infty,a]$. Likewise we find that $f$ is right-continuous at $a$ and this together implies that $f$ is continuous at $a$.
If $f$ is not uniformly continuous on $\mathbb R$ then some $\epsilon>0$ exists together with sequences $(x_n)_n$ and $(y_n)_n$ such that $|x_n-y_n|<\frac1{n}$ and $|f(x_n)-f(y_n)|\geq\epsilon$. Without loss of generality it can be assumed that $x_n<y_n$ for each $n$.
If the set $\{n\in\mathbb N:y_n\leq a\}$ is infinite then a subsequence $(n_k)_k$ can be found with $x_{n_k}<y_{n_k}\leq a$ leading to a contradiction with the fact that $f$ is uniformly continuous on $(-\infty,a]$. So we conclude that this set is finite. Likewise we conclude that the set $\{n\in\mathbb N:x_n\geq a\}$ is finite. So for $n$ large enough we will have $x_n<a<y_n$. 
Combined with $|x_n-y_n|<\frac1{n}$ this implies that both sequences $(x_n)_n$ and $(y_n)_n$ are convergent having $a$ as limit. Then $\lim_{n\to\infty}f(x_n)=f(a)=\lim_{n\to\infty}f(y_n)$ since $f$ is continuous at $a$.
We have: $$|f(x_n)-f(y_n)|\leq |f(x_n)-f(a)|+|f(a)-f(y_n)|$$
So the RHS will take a value smaller than $\epsilon$ for $n$ large enough, and a contradiction is found.
