avoid holding full stream in memory