Splitlines implementation which supports timeouts