Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
First time script running successful but next time getting error file got corrupted.
Start your test with a clean-up. For me it is a best practise to set the state of the environment under test. This might mean deleting some files or database records.
Now it could be a defect, if you expect the same script to be runnable over and over again.