Own ReadLine-like implementation.