**Lemma.** Let $f \colon X \to B$ is a proper, flat family of relative dimension $1$ with geometrically connected fibres. Let $\sigma_1,\ldots,\sigma_r$ for $r \geq 1$ be sections landing in the locus where $f$ is smooth. If all fibres $X_b \setminus \{\sigma_1(b),\ldots,\sigma_r(b)\}$ are affine, then $X \setminus \sigma_1(B) \cup \ldots \cup \sigma_r(B) \to B$ is affine.

*Proof.* The question is local on $B$, so we may assume $B = \operatorname{Spec} A$ is affine. For every $b \in B$ and every $i \in \{1,\ldots,r\}$, the point $\sigma_i(b) \in X_b$ is a Cartier divisor, since it sits in the smooth locus of $X_b$. Hence, $\sigma_i(B)$ is a relative effective Cartier divisor [Stacks, Tag 062Y]; in particular it is a Cartier divisor. Write $\mathscr L_i = \mathcal O_X(\sigma_i(B))$, and
$$\mathscr L = \bigotimes_{i=1}^r \mathscr L_i.$$
For any $b \in B$, we have $\deg((\mathscr L_i)_b) > 0$ on the component of $X_b$ containing $\sigma_i(b)$. Since $X_b \setminus\{\sigma_1(b),\ldots,\sigma_r(b)\}$ is affine, every component of $X_b$ contains at least one marked point. Hence, $\deg(\mathscr L_b) > 0$ on each component of $X_b$, so $\mathscr L_b$ is ample [Stacks, Tag 0B5Y].

Therefore, $\mathscr L$ is ample [Stacks, Tag 02DN], using that $B$ is affine (see [Stacks, Tag 01VK]). Then some multiple $\mathscr L^d$ for $d \gg 0$ is very ample and defines a closed immersion $X \to \mathbb P^N_B$ for some $N$. Then
$$d \sum_{i=1}^r \sigma_i(B) \in |\mathscr L^d|$$
is the intersection of $X \subseteq \mathbb P^N_B$ with a hyperplane, hence the complement $X \cap \mathbb A^N_B$ is affine. $\square$.

**References.**

[Stacks] A.J. de Jong et al, *The stacks project*.