Closed subset of a manifold is a submanifold if there exists a smooth retract. My question is regarding a specific exercise that I'm not really sure how to approach. Suppose I have a smooth manifold $M$ and let $A$ be a closed subset. Now suppose that there exists a smooth function $f:M \to A$ such that $f|_A = id$ (smooth retract). 
I want to show that $A$ is a submanifold, i.e, it is Hausdorff, second countable and locally euclidean. Hausdorff and second countable are both hereditary properties, so only the latter is left. 
My attempt was to prove that if $(U, \varphi)$ is a chart around $x \in A \subset M$ for $M$, then $\left(f(U), \varphi|_{f(U)}\right)$ is the desired chart. However, I'm not sure if $f(U)$ is open. I probably should use that $A$ is closed and $f$ is a retract, but I couldn't connect both facts. 
There is no need for a solution, just a hint is enough. 
PS: John Lee suggested that I should ask a question instead of leaving the exercise for the community, so here it is. I rewrote my previous post here. :) 
 A: Assume $M$ connected. Note that $A=Im(f)$ is therefore connected. Let $a\in A$, $f'(a)$ is a linear projection on $T_aM$. As the rank of a projection is a contious function on the set of projection (it is the trace), along $A$ the rank of $f'$ is constant $r$. Now, let us check that it is constant in a neigbourhood of $A$ . As $f\circ f= f$, $f'(f(p))\circ f'(p)= f'(p)$, and $f'(f(p))$ induces a isomorphism on $Im ( f'(p))$, so that the rank of $f'(p)$ is less than or equal to $r$. But the rank can only increase in the neigbourhood of $A$, so it is constant. If you know the "constant rank theorem" you are done. If not let us argue as follows.
Now choose a point $a\in A$. In order to study the image of $f$ near this point, let us choose  coordinates $x_1,...,x_n$ near $a$ such that $f'(a)$ is the projection onto $x_{r+1}==x_n=0$, and let us consider the new system of coordiantes $y_i=x_i\circ f$ for $i\leq r$, $y_i=x_i$  if $i> r$. There are functions $F_j, j>r$ such that $f(y_1,..y_n)=(y_1,,..,y_r, F_{r+1},...F_{n})$ Writing that the rank of $f'$ is $r$ we see that ${\partial F_j \over \partial y_k }=0$ if $k>r$. Or $f(y_1,...y_n)= (y_1,..,y_r, F_1(y_1,..) ..)$. So near $a$ the image of $F$ is just the graph of the function $F=(F_{r+1},...F_n$), a submanifold.
A: This not true. Consider two segments $C_1, C_2\subset R^2$ which are not parallel such that $C_1\cap C_2$ is a point. Take $A=C_1\bigcup C_2$ it is not a smooth manifold you have a singular point at the intersection. Consider $U_i$ a tubular neigborhood of $C_i, i=1,2$ diffeomorphic to $C_i\times [0,1]$. $X=U_1\cap U_2$ retracts to $A$ and is a manifold.
