A continuous function $\phi$ on $[a,b]$ is called piecewise linear provided there is a partition $a=x_0<x_1<\ldots<x_n=b$ of $[a,b]$ for which $\phi$ is linear on each interval $[x_i,x_{i+1}]$. Let $f$ be a continuous function on $[a,b]$ and $\epsilon$ a positive number. Show that there is a piecewise linear function $\phi$ on $[a,b]$ with $|f(x)-\phi(x)|<\epsilon$ for all $x\in[a,b]$.
I want to construct $\phi$ bit-by-bit starting from the left at $a$. I consider the set $C=\{c\mid$the linear function $\phi$ from connecting $f(a)$ and $f(c)$ satisfies $|f(x)-\phi(x)|<\epsilon$ for all $x\in[a,c]\}$. This set contains $a$ and also some interval close to it (since $f$ is continuous we can find $\delta$ such that $|f(a+y)-f(a)|<\epsilon/2$ for all $0<y<\delta$. Consider its least upper bound, and choose something slightly less than it. But I have no way to know why this process will eventually cover the entire interval $[a,b]$.