TITLE: A question on the compact subset
QUESTION [5 upvotes]: This is an exercise from a topological book.

Let $X$ is Hausdorff and $K$ is a compact subset of $X$. $\{U_i:i=1,2,...,k\}$ is the open sets of $X$ which covers $K$. How to prove that there exist compact subsets of $X$: $\{K_i:i=1,2,...,k\}$ such that $K=\cup^k_{i=1}K_i$ and for any $i\le k$, $K_i \subset U_i$?

What I've tried: I try to let $K_i = K\cap U_i$, then it is obvious $K=\cup^k_{i=1}K_i$, however, I'm not sure such $K_i$ is still compact in $X$. I don't know how to go on.
Could anybody help me? Thanks ahead:)

REPLY [3 votes]: If $x \in U_i$, since $K \backslash U_i$ is compact we can take disjoint open neighbourhoods $V$ and $W$ of $x$ and $K \backslash U_i$ respectively.  Then the closure of $V$ is  contained in $U_i$.  And so each $x \in K$ has an open neighbourhood $V_x$ whose closure is contained in some $U_i$.  These form an open cover of $K$, so we can take a finite subcover $V_1, \ldots, V_m$.  Let $K_i$ be the union of the closures of those $V_j$ whose closures are contained in $U_i$.