Changed sleep(0) to sleep(1) because it was causing problems.