Fixed script to run with crontab.