Are the fundamental groups of $X$ and $X/A$ isomorphic when $A$ is contractible?

Let $X$ be a topological space, $A$ a contractible subspace of $X$, and $f : X \rightarrow X/A$ the quotient map. I want to say that $f$ always induces an isomorphism between fundamental groups, or at least that it does under certain assumptions (e.g., when $X$ is a CW complex), but I do not see how to show this explicitly except when $X$ is a finite graph and $A$ is a tree in $X$. Is there a way to prove this in general, or at least in a more general case than finite graphs?

There is a result which states:

If the map $i:(A,x_0)\hookrightarrow (X,x_0)$ is a cofibration, and $A$ is contractible then the projection $p:(X,x_0)\to (X/A,\ast)$ is a homotopy equivalence.

In particular, if $(X,A,x_0)$ is a relative CW-complex, then the inclusion $i:(A,x_0)\hookrightarrow (X,x_0)$ is a cofibration. Since homotopy equivalences induce isomorphisms on fundamental groups, the induced map $$p_*:\pi_1(X,x_0)\to\pi_1(X/A,\ast)$$ is an isomorphism in this case.

To show this, let $$H:A\times I\to A,\quad H(a,0)=id_A(a)=a,\quad H(a,1)=x_0$$ be a homotopy giving $A\simeq\ast$. Since $i$ is a cofibration, this can be extended to a homotopy $K:X\times I\to X$ satisfying $$K(x,0)=id_X(x)=x,\quad K(a,1) = H(a,1)=x_0.$$ By the universal property of quotients, the map $K|_{X\times\{1\}}:X\to X$ factors through a map $k:X/A\to X$ such that $K|_{X\times\{1\}}=k\circ p$. Hence, $k\circ p\simeq id_X$.

Next, as $p\circ K|_{A\times I}=\ast$, $K$ factors through a homotopy $\overline{K}:X/A\times I\to X/A$ such that $\overline{K}\circ(p\times id_I)=p\circ K$. It's not hard to verify that $\overline{K}$ gives $id_{X/A}\simeq p\circ k$.

For a reference, everything presented above is in Switzer's Algebraic Topology, chapter 6.

The result isn't true in general.

Take $X=S^1$, $A=S^1 -\{N\}$, $N$ being the north pole. $A$ is contractible and $X/A$ is the Sierpiński space, which is contractible (and thus has a trivial fundamental group), but $X$ has a non-trivial fundamental group.