For a simple, really concrete example you can also look at: $A=k[x,y,u,v]/(xy+ux^2+vy^2)$, $X =Spec(A)$, $I=(x,y)$, $U = D(I)$. Then the functions $f=\frac{-v}{x}=\frac{y+ux}{y^2}$ and $g=\frac{-u}{y}=\frac{x+vy}{x^2}$ are defined on $U$. But $yf+xg=1$, so $U$ is affine! Cheers,