Why is $\lim_{x \to c}g(f(x)) = g(\lim_{x \to c}f(x))$ In this theorem (from the continuity section of the first chapter of a calculus textbook)

If $g$ is continuous at $b$, and $\lim_{x \to c}f(x)=b$, then $\lim_{x\to c}g(f(x)) = g(\lim_{x \to c}f(x))=g(b)$.

I would like an explanation (and proof) of $\lim_{x \to c}g(f(x)) = g(\lim_{x \to c}f(x))$.

The theorem mentioned is one of the most useful in calculating various limits. As an example if we need to calculate the limit of $\{f(x)\}^{g(x)}$ when $x \to a$ then we normally take logs. Say the limit is $L$ then $\log L = \log(\lim_{x \to a}\{f(x)\}^{g(x)})$ and then we exchange $\log$ and the limit operation. This is justified only because of this theorem. When we understand the usefulness and power of some result it makes us more curious to know the proof.
So let's us now understand why the theorem is true. I will avoid use of $\epsilon$ and $\delta$ as they tend to lose the expressive charm of language and ideas. We are provided that $f(x) \to b$ as $x \to c$. This means that we can make the value of $f(x)$ arbitrarily close to $b$ by taking values of $x$ sufficiently close to $c$. Note that $\epsilon$ and $\delta$ are used to quantify the terms mentioned in italics in the last sentence. Next we are given that $g(x)$ is continuous at $b$. This means that we make values of $g(x)$ arbitrarily close to $g(b)$ by taking $x$ sufficiently close $b$.
Next consider that while letting this $x \to b$ so that $g(x) \to g(b)$ we only try to use values of $x$ which form the values of the function $f$. Thus rather than $x$ tending to $b$ in any manner we prefer to have values of $x$ such that $x = f(t)$ (or $x$ takes values from range of $f$). Now we want values of $x$ sufficiently close to $b$ which can be done by taking values of $t$ sufficiently close to $c$. It thus follows that the value of $g(x) = g(f(t))$ can be made arbitrarily close to $g(b)$ by taking values of $t$ sufficiently close to $c$. In symbols $\lim_{t \to c}g(f(t)) = g(b) = g(\lim_{t \to c}f(t))$.
While reading the above the reader may fail to understand why continuity of $g$ at $b$ is necessary. In that case let's assume that $g$ is not continuous at $b$ and ask what happens then? Well then we may have the case that $g(x) \to L$ as $x \to b$, but $L \neq g(b)$ and then we only have $\lim_{t \to c}g(f(t)) = L$. So please understand that in any case we must have $\lim_{t \to c}g(f(t)) = \lim_{x \to b}g(x)$ provided these limits exist. In the special case when $g$ is continuous at $b$ we can write this limit as $g(b)$ and noting that $b = \lim_{t \to c}f(t)$ we can further write $$\lim_{t \to c}g(f(t)) = \lim_{x \to b}g(x) = g(b) = g(\lim_{t \to c}f(t))$$
So in the above identity the first and last equality always holds. It is the middle equality which needs continuity of $g$ at $b$.
Update: After having a look at this question I want to add some detail for the case when function $g$ is not continuous. In this case for the above argument to work it is essential that $f(x) \neq b$ in a certain neighborhood of $c$ (except possibly at $c$).
