I think you want to call the write/3 function here, so that you don't walk the iolist again.