Don't check for overlapping. Pick all sprites with Sprite.X>Line.X, and then among them pick a sprite with the lowest X.
There are several ways to pick by lowest X, you can use a loop:
Sprite compare X > Line.X
For Each Sprite Ordered by Sprite.X
... Line set X to Sprite.X
... Stop Loop