Proving $f$ is continuous iff all the functions parameterized are continuous

Let $$(Y,\tau)$$ and $$(X_i,\tau_i),i=1,2,...n$$ be the topological spaces. Further for each i , let $$f_i$$ be a mapping of $$(Y,\tau)$$ into $$(X_i,\tau_i)$$. Porve that the mapping $$f:(Y,\tau)\to\prod_\limits{i=1}^{n}(X_i,\tau_i)$$, given by $$f(y)=(f_1(y),f_2(y),...,f_n(y))$$ is continuous if and only if every $$f_i$$ is continuous.

My proof:

$$\rightarrow$$ Let $$U$$ be an open set of $$(\prod_\limits{i=1}^{n}X_i,\tau_i)$$ Suppose $$f$$ is continuous then $$f^{-1}(U)\in\tau$$

$$f_i(U)=p_i\circ f(U)$$ where $$p_i$$ is the projection $$p_i:(\prod_\limits{i=1}^{n}X_i,\tau_i)\to (X_i\tau_i)$$.

As $$f_i(U)$$ is a composition of two continuous functions hence it is continuous.

$$\leftarrow$$ Let $$U=U_1\times U_2\times...\times U_i\times...\times U_n$$ be an open set in the subspace topology $$f(Y),\tau_{nY}$$

Supposing $$f_i$$ is continuous forall the $$i=1,2...n$$ then

$$f^{-1}_i\circ p_i(U)=f^{-1}(U_i)\in\tau_i$$

But $$f^{-1}(U)=f^{-1}_i\circ p_i(U)$$ then $$f$$ is continuous.

Question:

Is my proof right? If not. Why not?

$$\leftarrow$$ Let $$U=U_1\times U_2\times...\times U_i\times...\times U_n \subset \prod_\limits{i=1}^{n}(X_i,\tau_i)$$ with each $$U_i$$ open $$X_i$$, so that $$U$$ is open in the product space. These open sets form a basis, so we only have to show that $$f^{-1}(U)$$ must be open in $$Y$$ to prove the continuity of $$f$$.