Changed how the _waitForFile method works.