Move the wait file mechanism to a utility function