Say $X$ is an algebraic variety and $U\subset X$ is open. Consider the natural map $U\rightarrow \operatorname{Spm}(\mathcal{O}_X(U))$ given by sending a point of $U$ to the ideal of sections over $U$ that vanish on that point. $U$ is affine if and only if this map is an isomorphism of varieties.
Is it enough to know $U$ is a bijection of sets? (It seems to me it should be! The ring of global sections on $\operatorname{Spm}(\mathcal{O}_X(U))$ is already $\mathcal{O}_X(U)$ right? So the rings already match! We just need to check that the sets match... what am I missing?)
EDIT (in response to comments by QiL):
First, let me add the assumption that $\mathcal{O}_X(U)$ is finitely generated as a $k$-algebra, so that $\operatorname{Spm}(\mathcal{O}_X(U))$ is an affine variety.
Second, let me state the definition of algebraic variety I'm working with: a separated prevariety. A prevariety is a quasicompact topological space with a sheaf of $k$-valued functions (for $k$ some algebraically closed field) such that every point is contained in an open set such that the restriction of the sheaf to that set makes it isomorphic (as a ringed space) to an affine variety. An affine variety is the $\operatorname{Spm}$ of a finitely generated reduced $k$-algebra.