wait until stream is ready before saving to file