$A$ and $B$ are connected sets. If the intersection of $A$ and $B$ is not empty, prove that the subspace $A \cup B$ is connected.
My proof: Assume that the union of $A$ and $B$ is not connected, then there exists a clopen set $U$ of the union of $A$ and $B.$ As $U$ is open, $M = U \cap A$ is open in $A,$ so the complement of $M$ is closed in $A.$
As $U$ is closed in $A \cup B$, the complement of (A u is open. So the complement of $M$ is open. So $M$ is a clopen subset and complement of $M$ is a clopen subset in $A.$ So $A$ is not connected. A contradiction. So $A \cup B$ must be connected.
I'm not sure if my proof is correct. Please help. thanks