Let a topological space $X$ have infinitely many connected components. Then why is it true that $X=X_1 \cup X_2$ where $X_1$ and $X_2$ are closed, disjoint nonempty?
For example $X=\mathbb{Q}$ has as its components each point, and $X=(-\infty, \sqrt{2}) \cup (\sqrt{2}, \infty)$.
Motivation:
I am trying to prove that in $\operatorname{Spec}A$, the connected components are clopen sets when $A$ is a noetherian ring. It suffices to show that there are finitely many connected components. A positive answer to this question would let me prove that there are finitely many connected components by contradiction - I would separate $\operatorname{Spec}A$ by two closed subsets and separate the one that is not connected(again by the positive answer to my question), and use that $A$ is noetherian to get a contradiction.