Modified the checking and playing file mechanism in the script.