Heisenberg's proof works in nice generality, but we can prove things more directly here.
Suppose that $f$ is unbounded. Then there is some sequence $(x_n)_{n=1}^\infty$ contained in the interval $[a,b]$ such that $\lim_{n\to\infty} f(x_n) = \infty$.
Now, consider the sequence $(x_n)$. If it is convergent, then it converges to some element within the interval $[a,b]$. That is, $\lim_{n\to\infty}x_n = \alpha$ for some $a \leq \alpha \leq b$. However, we then have that
$$
\infty = \lim_{n\to\infty} f(x_n) = f\Big(\lim_{n\to\infty}x_n\Big) = f(\alpha)
$$
since $f$ is continuous. However, this would imply that $f$ is not defined on the whole interval $[a,b]$! Hence this cannot happen.
Now, $(x_n)$ may not be convergent itself. However, it will (since it is a bounded sequence) have a convergent subsequence, and so you can apply this same argument to that subsequence to obtain the desired conclusion.