Or can we prove if A is both open and closed in the real line then it is empty or the whole line? Assuming the standard topology.
Let $A\subseteq \mathbb R$ and assume $A$ is neither $\varnothing$ nor $\mathbb R$.
Choose $a\in A$ and $b\in \mathbb R\setminus A$. Without loss of generality let's assume $a<b$ (otherwise just swap all of the inequalities henceforth).
Then $A\cap(-\infty,b]$ is nonempty (it contains $a$) and bounded above. By the supremum property it has a least upper bound $x$.
If $x\in A$, then $x<b$, and $(x,b]$ is disjoint from $A$. But that means that no neighborhood of $x$ is completely in $A$, so $A$ is not open.
On the other hand, if $x\notin A$, then $x$ must be a limit point of $A$ -- otherwise $A\cap(-\infty,b]$ would have an upper bound below $x$ contrary to assumptions. Therefore $A$ is not closed.
In either case $A$ is not both open and closed, Q.E.D.
No. You can prove that a topological space is connected iff the only clopen sets (sets that are both open and closed) are the empty set and the full space. The real line is clearly connected (as it is path-connected).