Let $(X,\tau)$ be a topological space. We say that a subset $S\subset X$ is connected iff there does not exist a set $A\subset X$ that is both open and closed in the induced topology. I need to prove the following:
A subset $S \subset X$ is connected if and only if cannot be written as a union of two disjoint subsets $H,K$, such that $S=H \cup K$ with $\overline H \cap K= H \cap \overline K=\emptyset$
$(\implies)$ Suppose that there exist $H,K\subset S $ such that $S=H \cup K$ with $\overline H \cap K= H \cap \overline K=\emptyset$. Then $S\setminus \overline H$ is open because $\overline H$ is closed by definition. Since we know that $\overline H \cap K=\emptyset$ and $S=H \cup K$, clearly $S\setminus \overline H \subset K$. I would like to show that $\overline H$ is also open, but I don't know how to do it; I thought about showing that its complement $S\setminus \overline H$ is closed using that $H \cap \overline K$ is empty but I am not able to do it.
$(\impliedby)$ Suppose $S$ is not connected. Then there exists a set $H\subset S$ such that $H$ is both open and closed. Take $K=S\setminus H$ and we are done. In fact, $S=H\cup (S\setminus H)$ by definition. On the other hand, $\overline H=H$ since $H$ is closed, so $\overline H \cap K=\emptyset$. Since $H$ is open, $K$ is closed, hence $H \cap \overline K=\emptyset$.
How can I show the first implication to be true? It seems simple, but I feel like I am missing something.