fix: open writeStream before write