Show that $f(X - D) \cap f(D) = \varnothing$ with $f$ continuous in $X$, $D$ dense in $X$ and $f|_{D}$ homeomorphism

Notice that the theorem specifically requires $X$ to be Hausdorff. That should suggest that after getting the points $x_1$ and $x_2$ you should take disjoint open nbhds of them, say $x_1\in V_1$ and $x_2\in V_2$. By your argument there is an open nbhd $U_2$ of $y$ such that $f[V_2\cap D]=U_2\cap f[D]$.

  • Show that there is an open $W_1$ in $X$ such that $x_1\in W_1\subseteq V_1$ and $f[W_1]\subseteq U_2$.
  • Deduce that $y\in U_2\cap f[D]$.
  • Derive a contradiction.