Let $Y$ be an affine open subset of a locally noetherian scheme $X$. Then, $X \setminus Y$ has pure codimension one [EGAIV$\_4$, Cor. 21.12.7]. Moreover, if $X$ is proper and of finite type over a field $k$, and $\dim X \ge 2$, then $X \setminus Y$ is connected [[Hartshorne](http://www.ams.org/mathscinet-getitem?mr=282977), Cor. II.6.2].


My question is the following:



> 
> If $X$ is a complex projective variety of dimension $\ge 2$, and $Y$ is a Zariski open
>  subset that is Stein, then is it still true that $X \setminus Y$ is
>  connected?
> 
> 
> 


The fact that $X \setminus Y$ is of pure codimension one is [[Neeman](http://www.ams.org/mathscinet-getitem?mr=932296), Prop. 3.4], and is a consequence of Hartog's theorem. Jing Zhang cites this proposition for the statement that $X \setminus Y$ is connected in [Algebraic Stein Varieties](http://www.ams.org/mathscinet-getitem?mr=2424914), specifically in the proof of Thm. 2.8, but it is not clear to me how Neeman's proposition implies this result.


It could also be true that the algebraic proof when $Y$ is affine can be modified in the case when $Y$ is Stein instead. But a key step in the proof by Hartshorne (and Goodman in his [original article](http://www.ams.org/mathscinet-getitem?mr=242843)) is that we can embed $Y$ into an affine space $\mathbf{A}^n$, then take its projective closure $\overline{Y}$ to get a compactification of $Y$, and compare this with $X$ using theorems about blow-ups from Nagata's [paper on compactifications](http://www.ams.org/mathscinet-getitem?mr=142549). I can't make this work in the Stein case.



Connectivity of complements of Stein opens
If you look at corollary 4.10 page 45 of the book of Banica and Stanasila titled Algebraic methods in the global theory of complex spaces,you will find a proof of the following .Any irreducible Stein space of dimension at least two has one end.This answers your question when X is irreducible .


