We had a situation: Rogue broke line of sight to enemies by running around the corner in complete cover a round ago.

Next round, the enemies move closer, two engage melee fighters and two stop in the middle of a corridor, shooting a PC who is out in the open with crossbows.

Rogue goes into stealth and wantS to pop out from behind the corner and shoot a crossbowman. Per rules he has to step out to make an attack so he has line of sight to shoot. The DM ruled, the moment that he steps out of his complete cover he loses his advantage for attack because he enters line of sight of the crossbowmen.

Does the rogue lose his bonuses for stealth as soon he enters line of sight, or does he keep it till he makes an attack?