If $p:E\to B$ is a covering space and $p^{-1}(x)$ is finite for all $x \in B$, show that $E$ is compact and Hausdorff iff $B$ is compact and Hausdorff

I'll try to answer the question without saying too much so that you can still work on it. I can edit my answer to give a complete solution if need be.

Let $\mathcal{U}$ be an open cover of $E$. Then for each $x\in B$ there exist $p^{-1}(x)$ is finite. Thus we can choose $U^x_1,\ldots, U^x_{n_x}\in\mathcal{U}$ such that $p^{-1}(x)$ is in the union of these sets.

Hints: Look at the image of $U^x_1,\ldots,U^x_{n_x}$ under $p$. Can you get an open set of $B$ from this containing $x$? How can you use this to get an open cover of $B$? How do you extract an open cover of $E$ from this information?