$\def\sK{\mathscr{K}} \def\sO{\mathscr{O}} \def\sL{\mathscr{L}}$(All definitions I will be using are explained in detail in Görtz, Wedhorn, Algebraic Geometry I, Ch. 11, Divisors.) Let $X$ be a scheme. A Cartier divisor is a global section of $\sK^\times_X/\sO_X^\times$, where $\sK_X=\mathscr{S}^{-1}\sO_X$ is the sheaf of meromorphic functions on $X$ (here $\mathscr{S}\subset\sO_X$ denotes the multiplicatively closed subsheaf of regular sections). A Cartier divisor is said to be effective if it lies in $\Gamma(X,(\sK_X^\times\cap\sO_X)/\sO_X^\times)$.
I am trying to understand the last step in the proof of the following result [ibid., p. 308]:
Proposition 11.34. Let $X$ be a scheme, let $\mathscr{L}$ be a line bundle on $X$, and let $R_{\mathscr{L}}$ be the set of $s \in \Gamma(X, \mathscr{L})$ that are regular. Then there is a natural bijection $$ \left\{\begin{array}{c} \text { effective Cartier divisors } D \\ \text { such that } \mathscr{O}_X(D) \cong \mathscr{L} \end{array}\right\} \leftrightarrow R_{\mathscr{L}} / \sim, $$ where $s \sim s^{\prime}$ if there exists an $a \in \Gamma\left(X, \mathscr{O}_X^{\times}\right)$ with $s^{\prime}=as$.
Proof. For an effective divisor $D$ and an isomorphism $\alpha: \mathscr{O}_X(D) \stackrel{\sim}{\rightarrow} \mathscr{L}$ the corresponding section $s \in R_{\mathscr{L}}$ is the image of the canonical section $s_D$ under $\alpha$. This yields a well defined map from the left hand side to the right hand side. Conversely let $s \in R_{\mathscr{L}}$. Choose an open covering $\left(U_i\right)$ of $X$ and isomorphisms $\mathscr{L}_{\mid U_i} \cong \mathscr{O}_{X \mid U_i}$. Then the images of $s_{\mid U_i}$ define local equations $f_i$ for an effective divisor $D$, which depends only on the equivalence class of $s$. The section $s$ then defines a monomorphism $\mathscr{O}_X \hookrightarrow \mathscr{L}$ which extends by definition to an isomorphism $\mathscr{O}_X(D) \stackrel{\sim}{\rightarrow} \mathscr{L}$. $\square$
It is the very last sentence of the proof that confuses me a little bit: I understand that $\sO_X\subset\sO_X(D)$, but I don't see how it follows “by definition” that $s:\mathscr{O}_X \hookrightarrow \mathscr{L}$ extends to an isomorphism $\mathscr{O}_X(D) \stackrel{\sim}{\rightarrow} \mathscr{L}$.
I can prove it by myself but my proof is not a one-liner. My sole question is:
From the theory developed in the book up until this point, is there a direct way to make this inference?
For completion, here's the proof I devised: Pick an open cover $X=\bigcup U_i$ and isomorphisms $\varphi_i:\sL|_{U_i}\cong\sO_{U_i}$ of sheaves of modules. Denote $D$ to the effective Cartier divisor represented by $(U_i,f_i)$, where $f_i$ is the image of $s|_{U_i}$ along $\varphi_i$. Then we have an actual equality $\sO_X(D)|_{U_i}=\sO_Xf_i^{-1}$ as subsheaves of $\sK_X$. Denote $t_i$ to the image of $1\in\sO_X(U_i)$ along $\varphi_i^{-1}$. Then $$ s=\varphi_i^{-1}\circ\varphi_i(s)=\varphi_i^{-1}(f_i)=f_it_i. $$ Define an $\sO_{U_i}$-linear morphism $\rho_i:\sO_Xf_i^{-1}\to\sL|_{U_i}$ that maps $gf_i^{-1}$ to $gt_i$. We claim the maps $\rho_i$ glue. Indeed, $\rho_i(gf_j^{-1})=\rho_i(gf_j^{-1}f_if_i^{-1})=gf_j^{-1}f_it_i$. Note it doesn't make sense to say that the latter equals $gf_j^{-1}s$, since $f_j$ might not be a section of $\sO_X^\times$ (i.e., $f_j^{-1}$ is a section of $\sK_X^\times$ that might not be in $\sO_X$) and $\sL$ is just an $\sO_X$-module. We overcome the trouble in the following way: we have $\varphi_j\rho_i(gf_j^{-1})=gf_if_j^{-1}\varphi_jt_i$, and since the latter expression lives in $\sK_X$, it equals $gf_j^{-1}\varphi_j(f_it_i)=gf_j^{-1}\varphi_js=gf_j^{-1}f_j=g$. Putting all together, $\rho_i(gf_j^{-1})=\varphi_j^{-1}\varphi_j\rho_i(gf_j^{-1})=\varphi_j^{-1}g=gt_j$. This shows $\rho_i$ and $\rho_j$ agree on intersections, so they glue to an $\sO_X$-linear map $\rho:\sO_X(D)\to\sL$. Then $\rho|_{\sO_X}=s:\sO_X\hookrightarrow\sL$, since for $g\in\sO_X(U_i)$, we have $\rho_i(g)=\rho_i(gf_if_i^{-1})=gf_it_i=gs$. Moreover, $\rho$ is an isomorphism, for it is locally an isomorphism: $\varphi_i\circ\rho_i(gf_i^{-1})=\varphi_i(gt_i)=g$, i.e., $\varphi_i\circ\rho_i$ is the canonical isomorphism $\sO_{U_i}f_i^{-1}\cong\sO_{U_i}$ of modules.