Let $(X,\mathcal{O}_X$ be a locally ringed space, and suppose that $U\subset X$ is an open set equipped with the sheaf of rings $\mathcal{O}_X|_U$ defined by $\mathcal{O}_X|_U(V)=\mathcal{O}_X(V)$ for all $V\subset U$. I am trying to show that this ringed space comes equipped with a natural monomorphism $\iota:U\rightarrow X$.
It is clear that $(U,\mathcal O_X|_U)$ is a locally ringed space, and moreover that the inclusion map $\iota:U\rightarrow X$ is an injection and thus a monomorphism in the category of topological spaces. We thus need to describe a map $\iota^\sharp: \mathcal O_X\rightarrow \iota_*(\mathcal O_X|_U)$. Let $V\subset X$ be open, and note that: $$\begin{align*} \iota^{-1}(V)=V\cap U \end{align*}$$ as if $x\in V\cap U$, then we have $x\in U$ and $x\in V$, hence $\iota(x)=x\in V$, so $x\in \iota^{-1}(V)$. If $x\in \iota^{-1}(V)$, then we have that $x\in U$, and $\iota(x)= x\in V$, so $x\in V$ and $U$. We thus define $\iota^\sharp$ on open sets as: $$\begin{align*} \iota^\sharp_V:\mathcal O_X(V)&\longrightarrow (\iota_*\mathcal O_X|_U)(V)=\mathcal O_X|_U(\iota^{-1}(V))=\mathcal O_X(U\cap V)\\ s&\longmapsto s|_{U\cap V} \end{align*}$$ We note that this commutes with restriction maps, as if $W\subset V$ then: \begin{align*} \iota^\sharp_W(\theta^V_W(s))=\theta^W_{W\cap U}\circ \theta^V_W(s)=\theta^V_{W\cap U}(s) \end{align*} while: \begin{align*} \theta^V_W\circ \iota^\sharp_V(s)=\theta^{V\cap U}_{W\cap U}\circ \theta^V_{V\cap U}(s)= \theta^V_{W\cap U}(s) \end{align*} so this is a morphism of sheaves. We check that $\iota^\sharp_x$ is a surjection for all $x$. Let $s_x\in (\iota_*(\mathcal O_X|_U))$, then for some $V\subset X$, and some $s\in \mathcal O_X(U\cap V)$, we have that $s_x=[V,s]$. However, we have that $[U\cap V,s]\in (\mathcal O_X)_x$, so trivially: \begin{align*} \iota^\sharp_x([U\cap V,s])=[U\cap V, s] \end{align*} We want to show that $[V,s]=[U\cap V, s]$. Let $W=U\cap V$, then we have that: \begin{align*} \theta^V_{U\cap V}(s)=\theta^{U\cap V}_{U\cap V}(s)=s \end{align*} so $\iota^\sharp_x$ is a surjection, and thus an epimorphism for all $x$. It follows that $\iota^\sharp$ is an epimorphism.
Since $\iota:U\rightarrow X$ is a monomorphism, and $\iota^\sharp$ is an epimorphism, does it follow that $\iota$ (I guess really the pair $(\iota,\iota^\sharp)$) is then a monomorphism? If not, then what is the issue?
Also, it seems $(\iota,\iota^\sharp)$ is an isomorphism onto itself, as restricting the image of $\iota$ we get a homeomorphism $\iota:U\rightarrow U\subset X$, and then $\iota^\sharp:\mathcal{O}_X|_U\rightarrow \iota_*(\mathcal O_X|_U)$ as defined is just the identity map on all open subsets of $U$, is this true?