Would be nice if this didn't create a (potentially very large) array. Couldn't we just stream the output to `sink` a chunk at a time, and avoid constructing this array?