Fix loop for streaming files