py, stream: Implement readlines for a stream.