The following situation appears in the proof of Proposition 1.9 in Fulton's Intersection theory.
Let $X$ be a $k$-dimensional affine variety (over a field), and let $V \subset X \times \mathbb{A}^1$ be a $k$-dimensional variety that dominates $X$ (wrt the projection). Let $A$ be the coordinate ring of $X$, so $X \times \mathbb{A}^1$ has coordinate ring $A[t]$, and $V$ corresponds to a prime ideal $\mathfrak{q} \subset A[t]$. Let $K = K(X) = Q(A)$ be the function field of $X$. Then the ideal $\mathfrak{q}K[t] \subset K[t]$ is a principal ideal, generated by some element $r \in K[t]$.
What is the geometric meaning of $r$, or what is its associated divisor $\operatorname{div}(r) \subset A_*(X \times \mathbb{A}^1)$?
Fulton claims that $[V] - \operatorname{div}(r) = \sum_i n_i [V_i]$ for some $k$-dim varieties $V_i$, which do not dominate $X$. How can I see that?
Let $\mathfrak{q} \subset A[t]$ denote any prime of height 1. Then, $\mathfrak{q} \cap A$ also has height at most 1. Since $A$ is a domain, there are two possibilities: $\mathfrak{q} \cap A$ has height 1, or $\mathfrak{q} \cap A = (0)$. Primes $\mathfrak{q}$ of the first kind we will call type 1, and those of the second kind type 2.
Geometrically, $\mathfrak{q}$ is the generic point of a closed subvariety $V$ of $X \times \mathbb{A}^1$ of codimension 1, i.e. a prime divisor, and $\mathfrak{q} \cap A$ is the generic point of $\overline{\pi(V)}$, where $\pi: X \times \mathbb{A}^1 \rightarrow X$ is the projection. Therefore, points of type 2 are precisely those corresponding to subvarieties $V$ that dominate $X$.
So, Fulton is showing that if $\mathfrak{q}$ is of type 2, then $[\mathfrak{q}]$ is linearly equivalent to a linear combination of some $[\mathfrak{q}_i]$, where each $\mathfrak{q}_i$ is of type 1. Here is the argument, which you began to describe. First of all, observe that there is a one to one correspondence between primes of $A[t]$ of type 2 and nonzero primes of $K[t]$, since $K[t]$ is the localization of $A[t]$ at $A - \{0\}$. For any such $\mathfrak{q}$, write $\mathfrak{q} K[t] = (r)$, for $r \in A[t]$ (clear denominators if necessary). Now, $r \in \mathfrak{q}K[t] \cap A[t] = \mathfrak{q}$, and so $[\mathfrak{q}]$ appears in $\text{div}(r)$. However, no other primes of type 2 appear in $\text{div}(r)$; such a prime $\mathfrak{q}'$ would contain $r$. In that case, we get $\mathfrak{q}'K[t] \supset (r) = \mathfrak{q}K[t]$, which implies $\mathfrak{q}' = \mathfrak{q}$, since $\mathfrak{q}K[t]$ is maximal.
Therefore, $\text{div}(r)$ is a linear combination $[\mathfrak{q}] + \sum_i n_i [\mathfrak{q}_i]$, where $\mathfrak{q}_i$ is type 1, i.e. corresponds to a closed subvariety $V_i$ which does not dominate $X$.
Edit: Mohan gave the same argument (more concisely) in the comments before I posted. Also, another reference is Proposition II.6.6 in Hartshorne.