Splitting a stream based on a simple condition