meromorphic sections of invertible sheaves and divisors on a Riemann surface

Let $(X,\mathcal O_X)$ (here $\mathcal O_X$ is the sheaf of holomorphic functions) be a compact Riemann surface and let $D=\sum_{x\in X} a_x[x]$ be a divisor on $X$. The invertible sheaf associated to $D$ is $$\mathcal O_X(D)(U)=\{f\in\mathscr M_X(U)^\ast: \operatorname{ord}_x(f)+a_x\ge 0 \quad\text{for any x\in U}\}\cup\{0\}$$ where $\mathscr M_X$ is the sheaf of meromorphic functions. Now let $\mathcal L$ be an invertible sheaf on $X$ an let $s\in\mathcal (\mathcal L\otimes_{\mathcal O_X}\mathcal M_X)(X)$ be a non-zero meromorphic section of $\mathcal L$. Then we can associate a divisor to $s$ that we denote with $\operatorname{div}(s)$.

Informally $s$ is given as a colletion of "compatible" meromorphic functions on a trivialization covering for $\mathcal L$ and the order of $\operatorname{div}(s)$ at a point $x\in X$ is defined as the order of the right merormophic function at that point (I can be more precise on the definition of $\operatorname{div}(s)$ if you want).

Problem: I don't understand why we have that $\mathcal O_X(\operatorname{div}(s))\cong \mathcal L$.

Can you help me in proving this?

Here is just a rough sketch. Let $f \in \mathcal O_X(div(s))(U)$, and map it to $fs \in \mathcal L(U)$. To see this map is surjective, notice if $s'$ is any other nonzero section, then $div(s/s')$ is principal, and the meromorphic function $f$ with $div(s/s')$ will lie in $\mathcal O_X(div(s))$. To see the map is injective, if $fs=0$, then after trivializating, $fs=0$ and since $s$ is a nonzero meromorphic function, $f$ will need to be zero. This argument needs many more details!
Weil divisor on a Riemann surface is Cartier: there is an open cover $\{U_\alpha\}$ and meromorphic functions $f_\alpha$ on $U_\alpha$ s.t. $D|_{U_\alpha} = (f_\alpha)$. Transition functions of the invertible sheaf $\mathcal{L}$ are $g_{\alpha \beta}= \frac{f_\alpha}{f_\beta}$ on $U_{\alpha \beta}= U_\alpha \cap U_\beta$. Note that $g_{\alpha \beta}$ are holomorphic on $U_{\alpha \beta}$.
If $s$ is a meromorphic section then is a collection of meromorphic functions $\{s_\alpha\}$ s.t. $s_\alpha = g_{\alpha \beta} s_\beta$. But then collection $\frac{f_\alpha}{s_\alpha}$ is a globally defined meromorphic function. So, the divisor of $s$ is equivalent to the given divisor $D$: they only different by the principal divisor of this meromorphic function. It is clear from your definition that equivalent divisors give isomorphic invertible sheaves.