Let $X,Y$ be compact Hausdorff spaces. Let $f:X\to Y$ be one-to-one, onto and continuous. Show that $f$ is a homeomorphism.
I came up with this "proof" but I am very sure it is wrong. In order to show that $f$ is a homeomorphism, we only need to show that $f^{-1}$ is continuous. So I considered an open set $U\subset X$, and wanted to show that $f^{-1}(U)$ is open in $Y$. Suppose that's not the case, then $f^{-1}(U)$ is closed in $Y$. Then its preimage $f^{-1}f^{-1}(U)$ is closed in $X$ since $f$ is continuous. Then that implies that $U$ is closed in $X$, a contradiction.
I feel like I messed up with the last part. Also, how do I use "compact" and "Hausdorff" here? I know that a compact set in a Hausdorff space has to be closed.