rework file waiting to use stat instead of opening needlessly.