I think you should expand on a few things in the proof. An immediate red flag that you aren't being very rigorous is when you don't explicitly mention the assumptions of the proof in your logic. You never referred to the fact that each $E_j$ is connected. Moreover, you referred to a function $f$ and then didn't really use it. That's fine, you don't really need to phrase this short proof in terms of continuous functions, but you should pick one approach and stick to it.
Starting from the beginning, I would also not start by assuming the existence of such a continuous function $f$. Why should it exist? This function exists because you are assuming $E$ is disconnected, and is therefore the disjoint union of nonempty open sets $A$ and $B$. 'Open' is important because then you can verify that the function $f$ mapping $A \rightarrow 0$ and $B \rightarrow 1$ is continuous (as the preimages of $\{0\}, \{1\}$, and $\{0,1\}$ ($A,B$, and $E$, respectively) are open by construction.
Now you can use this continuous function $f$ to be rigorous. Continuous functions map connected sets to connected sets, so $f(E_j) = 0$ or $f(E_j) = 1$. Therefore the image under $f$ of $E_j$ is determined by any point of $E_j$. Since we assume the $E_j$ have nonempty intersection, pick a point $x$ in their intersection to see $f(E_i) = x = f(E_j)$ for all $i,j$. Then $f(\bigcup_j E_j) = \bigcup_j f(E_j) = \bigcup_j f(x) = f(x)$.