isometry on compact space

I need to prove that an isometry $f$ on a compact metric space $X$ is necessarily bijective. I've got most of the proof, but I can't figure out why any point in $X-f(X)$ would necessarily have to have some open neighborhood disjoint from $f(X)$.


Solution 1:

$f(X)$ is compact. If $x_0\notin f(X)$, because $X$ is separated for all $x\in f(X)$ exists two disjoints open sets $U_x$ and $V_x$ such that $x_0\in U_x$ and $x\in V_x$. We can find $n\in\mathbb N$ and $x_1,\cdots,x_n\in f(X)$ such that $f(X)\subset \bigcup_{j=1}^nV_{x_j}$. Now put $U:=\bigcap_{j=1}^nU_{x_j}$.