haa!! suppose $K$ is not closed, and $\alpha$ is a limit of $K$ while not being in $K$. Then $f:K \to \mathbb R$, $f(x)=\frac{1}{|x-\alpha |}$ is not bounded! so indeed, if every continuous real valued function is bounded, then $K$ is compact. —
Oria Gruber 1 min ago