You are right to conclude from Heine-Borel that a compact set is closed and bounded. Since the set is bounded it has a greatest lower bound and a least upper bound. But you need to prove why they are contained in the compact set. You need that the set is closed, but it isn't sufficient to say "because the set is closed".
Here I improved the argument:
Let be $K$ a compact subset of $\mathbb R$. Heine-Borel yields that $K$ is bounded hence it has a greatest lower bound $R$ and a least upper bound $r$.
Since $R$ is the least upper bound, there exists a sequence $(x_n)_n\subset K$ such that $x_n\to R$. Since $K$ is closed by Heine-Borel we conclude $R\in K$. Analogous we get $r\in K$.