Prove $\Delta_X$ is closed iff X is Hausdorff [duplicate]

This question already has an answer here:

I'm attempting a topology proof and think my proof is correct but I'm not 100% sure. The problem is as follows: Define $\Delta_X=\{(x,x)\in X\}$. Prove that $X$ is Hausdorff if and only if $\Delta_X$ is a closed set. The reverse proof is fine but for my proof of the forward one I attemopted as follows.

Assume $\Delta_X$ is closed, then $D=(\Delta_X)^C$ is open. Let $p_1,p_2\in D$ then $p_1 \neq p_2$. Take a union of open sets $U=\cup_{\alpha \in A}U_{\alpha}$ such that $p_1,p_2 \in U$. If $p_i \in U_{\alpha_i}$ with $U_{\alpha_1} \cap U_{\alpha_2} = \varnothing$ then we're done. If not, then $p_1,p_2$ are contained in the same open set. Write this set as a union of open sets such that $p_1$ and $p_2$ are not contained in the same open set. Therefore, $X$ is Hausdorff.

I'm not sure if this is correct but if it isn't any comments on where it is wrong and hints at improving it would be greatly appreciated!

marked as duplicate by Mario Carneiro, Joey Zou, R_D, Cameron Williams, user91500Oct 5 '16 at 6:20

You're supposed to prove that given $p_1,p_2\in \color{red}{X}$ with $p_1 \neq p_2$, there are disjoint open sets containing $p_1$ and $p_2$, respectively. If $p_1$ and $p_2$ are distinct points of $X$, then $(p_1,p_2)\notin \Delta_X$. So there is a basic open set $U \times V$ of $X \times X$ containing $(p_1,p_2)$ which is disjoint from $\Delta_X$. Now show that $U$ is disjoint from $V$.
• I think I see now. So to prove $U$ and $V$ are disjoint, you could assume they're not, therefore they have point in common which is a contradiction since $U \times V$ is disjoint from $\Delta_X$ ? – Crunch Oct 4 '16 at 21:55