Let $(M,d)$ be a metric space. If $K\subset M$ is compact, then it is closed (and bounded).
Proof Let's see that $M\setminus K$ is open. Let $x\in K$ $\exists \varepsilon_1 (x), \varepsilon_2(x) \text{ so that } B(x, \varepsilon_1(x))\cap B(y,\varepsilon_2(x)) = \emptyset$ then $K \subset \cup_{x\in K} B(x, \varepsilon_1(x))$ and, since $K$ is compact $\exists N \in \mathbb N \; \exists x_1,...,x_N \in K$ s.t. $ K\subset \bigcup_{i=1}^N B(x_i, \varepsilon_1(x_i)) $ let $r = \min\{\varepsilon_2(x), i = 1,...,N \} > 0$, then $ B(y,r)\cap B(x_i, \varepsilon_1(x_i)) = \emptyset \quad\forall i = 1,...,N $ therefore $B(y,r)\subset M\setminus K$ and $K$ is closed.
Question Why uses $\varepsilon_1(x)$ and $\varepsilon_2(x)$? If we consider, in $\mathbb R$ the interval $[0,1]$ it can't be covered using open balls without covering elements of $\mathbb{R}\setminus[0,1]$, so what happens when choosing $r$? Am I missing something?
Thanks in advance.