Restriction continuous function to be homeomorphism Let $X$ be a compact space and $Y$ be a Hausdorff space and let $f$ be a continuous function from $X$ to $Y$. Let 

$$S:=\{y\in Y\mid \text{ the preimage of }y \text{ consists only one point}\}$$ 

and set $$h:=f |_{f^{-1}(S)}.$$
Show that $h$ is homeomorphism from $f^{-1}(S)$ to $S$.

My attempt. Notice that $h$ is 1-1 and onto. It suffices to show that $h$ is closed. We claim that $S$ is closed. Then the rest is easy. However, I have trouble to prove my claim.
Cloud anyone help to prove it or give another suggestion 
 A: As pointed out in the comments, $S$ need not be closed.  However, the fact that $f$ is a closed map can still be used to show that $h$ is a closed map and hence a homeomorphism.
Indeed, more generally, let $f:X\to Y$ be any closed map, $S\subseteq Y$ be any subset, and $h:f^{-1}(S)\to S$ be the restriction of $f$.  Then I claim $h$ is also closed.  To prove this, let $C\subseteq f^{-1}(S)$ be closed (as a subset of $f^{-1}(S)$) and suppose $y\in \overline{h(C)}\cap S$.  Let $D$ be the closure of $C$ in all of $X$; then $f(D)$ is closed and contains $h(C)$ and thus $y\in f(D)$.  Choose some $x\in D$ such that $y=f(x)$; then $x\in D\cap f^{-1}(S)=C$.  But since $y\in S$, there is only one $x\in X$ such that $f(x)=y$.  Thus actually $y=h(x)\in h(C)$.  This shows that $h(C)$ is closed in $S$.
A: Given the definition of $S$ as above, it is useful to note that for any $A\subseteq X$, we have that $f(A\cap f^{-1}(S))=f(A)\cap S$. 
One inclusion, $$f(A\cap f^{-1}(S))\subseteq f(A)\cap S,$$  is a basic result of set theory. For the other, let $y\in f(A)\cap S$. Then $\exists x\in A$ such that $f(x)=y$. Since $y\in S$, $\exists x_1\in  f^{-1}(S)$. By the definition of $S$, though, $x=x_1$ so $x\in f^{-1}(S)$, i.e. $x\in A\cap f^{-1}(S)$ and $y=f(x)\in f(A\cap f^{-1}(S))$, so the inclusion holds.
Now, let $C$ be a closed set in $f^{-1}(S)$. Then $C=D\cap f^{-1}(S)$ for some closed $D\subseteq X$. Then $$f(C)=f(D\cap f^{-1}(S))\\=f(D)\cap S
$$ 
Since $X$ is compact, then so is $D$, which means that $f(D)$ is a compact subset of a Hausdorff space, i.e. $f(D)$ is closed, whence $f(D)\cap S$ is closed in $S$. 
