Question:
Let $(X, d)$ be a metric space such that for every subset $E$ satisfying $E\neq \emptyset$, $E\neq X$, we have $\overline{E}\cap\overline{X\setminus E}\neq \emptyset$. Prove that $X$ is connected. (overlines indicate closures)
Solution:
Assume for a contradiction that $X$ is not connected. Then there exist nonempty sets $A, B\subset X$ such that $X=A\cup B$ and $\overline{A} \cap B = \emptyset$, $A\cap \overline{B}=\emptyset$. In particular $A$ and $B$ are disjoint, so $B = X\setminus A$. Note that $A\neq \emptyset$ by assumption, and $A\neq X$ because $X\setminus A = B \neq \emptyset$. Hence $\overline{A}\cap \overline{X\setminus A}\neq \emptyset$, i.e. $\overline{A}\cap \overline{B}\neq \emptyset$. So let $x\in \overline{A}\cap \overline{B}$, i.e. $x\in \overline{A}$ and $x\in \overline{B}$. $x\in X = A\cup B$, so $x\in A$ or $x\in B$. If $x\in A$, then $x\in A\cap \overline{B}$, so $A\cap \overline{B}\neq \emptyset$. If $x\in B$, then $x\in \overline{A}\cap B$, so $\overline{A}\cap B\neq \emptyset$. Both cases lead to a contradiction. Hence $X$ is connected.
Confusion:
I basically proved it the exact same way but I got stuck trying to show that $x$ is indeed in $X$ (I just assumed at first and then felt that I can't necessarily do that). So $X = A\cup B$, but $x\in \overline{A}\cap\overline{B}$ could be such that $x$ is a limit point of both that is not also in either $A$ or $B$, since we have no information on whether $X, A, B$ are closed. I am not sure how you show that $x\in X$. The solution states that $X$ is actually closed (not in the question statement), but I don't see how.
It seems that you have doubts whether $x \in \overline A \cap \overline B$ is contained in $X$.
The closure of a subset $C \subset X$ is the set $$\overline C = \{ x \in X \mid \text{Each open neighborhood $U$ of $x$ in $X$ has non-empty intersection with $C$} \} .$$ Therefore by definition $\overline C \subset X$. It wouldn't make any sense to add points outside of $X$ to $\overline C$.
Thus $\overline A \subset X$ and $\overline B \subset X$. Hence $\overline A \cap \overline B \subset X$, in particular $x \in X$.