Replaced handwritten loop with Scalaz' stream.unfold.