The problem statement (verbatim):
Prove or disprove:
Let $A\subseteq \mathbb R$. If every continuous function $f:A\to\mathbb R$ is bounded then $A$ is a compact set.
I know the converse is true. If $A$ is compact then the image set of a continuous function over $A$ must be compact.
My attempt:
We have that every continuous function $f:A\to \mathbb R$ is bounded.
There could be a case where $A$ is a finite set of discrete points. Every function over $A$ shall be continuous because all its points are isolated. $A$ is compact as required because it is bounded and does not have any limit points.
Suppose if possible, $A$ is not bounded. WLOG, we may assume that there exists a point $c$ such that $(c,\infty)\subseteq A$. Consider the function $f(x)=x^2$, it is continuous everywhere and on $A$ as well. However, $f(A)$ is not bounded as $\lim_{x\to\infty} f(x)=\infty$. Thus, not all continuous functions are bounded. We have a contradiction.
Suppose if possible, $A$ is not closed. There exists a sequence $\{x_n\}$ in $A$ which converges to a point $b$ which is outside $A$.
WLOG, we may assume that $(b,c)\subseteq A$ but any $\delta$-neighborhood $(b-\delta,b+\delta)$ of $b$ is not fully contianed in $A$.
Consider $f(x)=\frac{1}{x-b}$ which is continuous everywhere on $\mathbb R\setminus \{b\}$. It is also continuous on $A$. However, $\lim_{x\to b^+}f(x)=\infty$ so $f(A)$ is not bounded. We have a contradiction again.
Thus, $A$ must be both closed and bounded, and hence, compact. $\blacksquare$
Is my proof correct? I also want to see alternative proofs.