Exercise 1.1.18 in Hatcher's Algebraic Topology Background

I am currently trying to solve exercise 1.1.18 in Hatcher's Algebraic Topology. The part of the exercise I am interested in is the following:


  Using the technique in the proof of Proposition 1.14, show that if a space $X$ is obtained from a path-connected subspace $A$ by attaching an n-cell $e^n$ with $n ≥ 2$, then the inclusion $A \hookrightarrow X$ induces a surjection on $\pi_1$ .


I know that $i:A \hookrightarrow X$ induces a homomorphism $i_*:\pi_1(A)\rightarrow \pi_1(X)$, so I only need to show this is a surjection. I think I understand the idea of the proof, which is to show that every loop $f\in \pi_1(X)$ is homotopic to a loop which is contained entirely in $A$. Hatcher's suggestion is to follow the proof $\pi_1(S^n)=0$ for $n\geq 2$, meaning that we should be able to push the sections of $f$ which are in the attached $n$-cell $e^n$ out. This is causing me a bit of trouble.

Attempt

Since $X$ is defined to be the result of attaching an $n$-cell to $A$ via some attaching map $\varphi:\partial D^n\rightarrow X$, it has the form $X=A \amalg e^n/\sim$, where $x\sim \varphi(x)$ for all $x \in \partial D^n$. Note first that since $A$ and $e^n$ are path connected, the adjunction space $X=A\cup_\varphi e^n$ is path connected. As such, our choice of base point does not affect the structure of $\pi_1(X)$, so let $x_0 \in A$ be the base point of $\pi_1(X)$ we are working over. Let $f \in \pi_1(X,x_0)$. Let $E=\text{Int}(e^n)$ and consider $f^{-1}(E)$. This is an open subset of $(0,1)$, so it is the union of a possibly infinite collection of subsets of $(0,1)$ of the form $(a_i,b_i)$. Let $f_i$ denote the restriction of $f$ to $(a_i,b_i)$. Note that $f_i$ lies in $e^n$ and, in particular, $f(a_i)$ and $f(b_i)$ lie on the boundary of $e^n$, so they are elements of $A$. For $n\geq 2$ we can homotopy $f_i$ to the path $g_i$ from $f(a_i)$ to $f(b_i)$ that goes along the boundary of $e^n$, which is homeomorphic to $S^{n-1}$, so it is path connected for $n\geq 2$. Since $e^n$ is homeomorphic to $D^n$, where $n\geq 2$, it is simply connected so $f_i$ and $g_i$ are homotopic. Repeating this process for all $f_i$, we obtain a loop $g$ homotopic to $f$ such that $g(I)\subseteq A$. 

What really bothers me about this is how I could homotopy form a homotopy from $f$ to $g$ consisting of possibly infinitely many individual homotopies from $f_i$ to $g_i$. I believe I need there to only be finitely many $f_i's$, but I don't see how to show it. 

Note: This is not homework.
Proof with Yoyo's suggestion

Since $X$ is defined to be the result of attaching an $n$-cell to $A$ via some attaching map $\varphi:\partial D^n\rightarrow X$, it has the form $X=A \amalg e^n/\sim$, where $x\sim \varphi(x)$ for all $x \in \partial D^n$. Note first that since $A$ and $e^n$ are path connected, the adjunction space $X=A\cup_\varphi e^n$ is also path connected. As such, our choice of base point does not affect the structure of $\pi_1(X)$, so let $x_0 \in A$ be the base point of $\pi_1(X)$ we are working over. Let $f \in \pi_1(X,x_0)$. Let $E=\text{Int}(e^n)$ and consider $f^{-1}(E)$. This is an open subset of $(0,1)$, so it is the union of a possibly infinite collection of subsets of $(0,1)$ of the form $(a_i,b_i)$. Let $x \in E$ and let $U$ be an open ball around $x$ in $e^n$. Like before, $f^{-1}(U)$ is an open subspace of $(0,1)$, so it is of the form $(c_i,d_i)$ for possibly an infinite number of $i$'s.  The preimage $f^{-1}(x)$ is a closed subspace of $I$, hence it is compact. The intervals $(c_i,d_i)$ form an open cover of $f^{-1}(x)$, hence a finite collection of these intervals cover $f^{-1}(x)$. Let $f_i$ denote the restriction of $f$ to $(c_i,d_i)$. Note that $f_i$ lies in the closure of $U$ and, in particular, $f(a_i)$ and $f(b_i)$ lie on the boundary of $U$. For $n\geq 2$ we can homotopy $f_i$ to the path $g_i$ from $f(a_i)$ to $f(b_i)$ in the closure of $U$ which is disjoint from $x$, since the closure of $U$ is homeomorphic to $D^{n}$, a closed and convex subset of $\mathbb{R}^n$. This gives a homotopy from $f$ to the path $g$, which is disjoint from $x$. Since $g$ is not surjective, it is homotopic to a path $h$ contained entirely in $A$.
Since $\pi_1(S^n) =0 $ for $n&gt;1$ so all elements of $\pi_1(X)$  can be realized as an element os $\pi_1(A)$.