I'm facing an algebraic topology exercise, and I only need to prove that in the title to finish it:
Let $f: I \to \mathbb{R}^{n}$ a continuous path that passes through the unit sphere $D^{n} = \{ x \in \mathbb{R}^{n} \mid ||x|| \leq 1\}$ i. e. $f(I) \cap D^{n} \neq \emptyset$. Prove that the path goes inside the sphere only finitely many times.
What I've done so far is this: Since $f$ is continuous, $f^{-1}(B = D^{n} \setminus S^{n-1})$ is an open set, and in this case is also a union of open disjoint intervals $f^{-1}(B) = \bigcup_{\alpha \in L} (a_{\alpha},b_{\alpha})$. I have not found a way to ensure that $L$ es finite.
Intuition tells me it's true, although that's not the actual exercise. Anyone please help me to prove or disprove it. Thanks.
Now that I've been proved wrong I would like you to help me with the original excercise: Let $A$ be a path-connected space and $f: S^{n-1} \to A$ continuous. Let $X = A \cup_{f} D^{n} = (A \cup D^{n})/(a \sim f(a))$. Prove that if $n \geq 2$ then the natural mapping $i: A \to X$ induces a surjection on the foundamental groups.
I was trying to get the pre-image over $A$ of every loop in $X$. The only problem of this would be when the loop passes through the disc $D^{n}$ (which is "outside" $A$), but in such case I could deform it and take it to its boundary $S^{n-1}$, which is identified with $A$. This idea was taken from Hatcher's proof of $\Pi_{1}(S^{n}) = 0$, $n \geq 2$. The thing is that he is able to ensure that the loop goes inside the ball only finitely many times, so the homotopy is well-defined. So, given that I am not able to do so, how can I ensure my the homotopy to be well defined?

See page 35 of Hatcher's Algebraic topology book. It is freely available on his homepage: http://www.math.cornell.edu/~hatcher/AT/ATpage.html The proof of proposition 1.14 is probably exactly what you want, so I am not going to repeat it here.