Can I please receive help/feedback on my proof? Thank you for your time and help!

Suppose $X$ is a topological space, $A\subseteq X, f: X\to A$ is continuous and for each $a\in A, f(a) = a.$ Prove that $A$ is closed in $X.$

$\textbf{Solution:}$ Let $(x,y)$ be a Hausdorff space and let $f$ be a continuous mapping of $X$ into itself. Then the set $A= \{x\colon f(x) = x\}$ is closed. We shall show $X\setminus A$ is open. If $X\setminus A = \emptyset$ then it is clearly open. So let $X\setminus A \ne \emptyset$. Let $a$ be an arbitrary point of $X\setminus A$. Then $f(a) \ne a.$ Since $X$ is a Hausdorff space and $f(a), a$ are distinct points of $X$, there exist disjoint open sets $G$ and $H$ such that $f(a) \in G$ and $a\in H$. As $f$ is continuous, $f^{-1}(G)$ is an open set containing $a$. So $f^{-1}(G)\cap H$ is an open set containing $a$. 

We claim $f^{-1}(G) \cap H \subseteq X\setminus A.$ Let $z\in f^{-1}(G) \cap H.$ Then $f(z) \in G, z\in H.$ Since $G\cap H = \emptyset, f(z) \ne z.$ So $z\notin A$, i.e. $z\in X\setminus A.$ Thus for each $a\in X\setminus A,$ there exists an open set $f^{-1}(G)\cap H$ such that $a\in f^{-1}(G)\cap H \subseteq X\setminus A.$ Hence, $X\setminus A$ is in a neighborhood of each of its points and so it is open.