$f\colon X \to Y \times Z$ is continuous iff its component functions are

I have a homework question that asks me to prove that a given function $f : X \rightarrow Y \times Z$ is continuous if and only if its component functions $f_Y : X \rightarrow Y$ and $f_Z : X \rightarrow Z$ are continuous. I think I solved it, and looking around online, I see that my proof is the same as the one given in various textbooks, so it must be right. But thinking about it further, I'm no longer convinced it is.

My question regards the reverse direction: if the component functions are continuous then $f$ is. My thought was that $f^{-1}(U \times V) = f_Y^{-1}(U) \cap f_Z^{-1}(V)$, so it will be open if $U$ and $V$ are and $f_Y$ and $f_Z$ are continuous, thus showing that $f$ is continuous. This answer seems to be the same answer given in various places online. However, it looks to me that this only works for open sets of the form $U \times V$. The definition of a continuous function (at least the one we're using in class) states that "A function is continuous iff every open set in the range has an open preimage." So why is this proof acceptable? It only considers "rectangular" open sets in the range, not all of them.

-
@Zev: I know I voted to close as duplicate, but Paul is not asking for a proof, so I actually changed my mind about that... he's asking about a point in the proof. –  Arturo Magidin Nov 1 '11 at 4:22
Um, please reopen my question... The linked question addresses the forward direction only; my question involves the converse... –  Paul Accisano Nov 1 '11 at 4:22
@Paul: Apologies, Arturo and I acted too quickly. –  Zev Chonoles Nov 1 '11 at 4:23
@Paul: Sorry about that; I had actually found two separate questions, each addressing one of the directions: this and this, but the software only allows one to link to one of the questions; and in any case, I noticed later that you are not asking for a proof, you are asking about a point on the proof, so it's not quite a duplicate. Sorry for the confusion. –  Arturo Magidin Nov 1 '11 at 4:26

The reason it suffices to consider only the "rectangular open sets" is that the rectangular open sets are a basis for the product topology: every open set in $X\times Y$ is a union of "rectangular open sets". So it suffices to check for the rectangular ones:
If $O$ is an arbitrary open set of $X\times Y$, we can find rectangles $U_i\times V_i$ with $U_i$ open in $X$ and $V_i$ open in $Y$, such that $$O = \bigcup_{i\in I} (U_i\times V_i).$$ Then $$f^{-1}(O) = f^{-1}\left(\bigcup_{i\in I}U_i\times V_i\right) = \bigcup_{i\in I}f^{-1}(U_i\times V_i).$$ So $f^{-1}(O)$ is a union of open sets (since we already established that the inverse image of a "rectangular open set" is open), hence open.
Ah, that "every open set in $X \times Y$ is a union of 'rectangular open sets'" bit is the part I didn't see. Many thanks =) –  Paul Accisano Nov 1 '11 at 4:28