pass in a writeable stream rather than a filename