Added a wait for file to have proper permissions when not root user.