use stream instead of file