Dennis also makes an excellent point. If the values held in divno are not character values, your program will throw-up everytime. You stated that you get a few records before the program stops. If, for example, the program stops at record #4, I'd look hard at the data in records 3,4,5, & 6.
If the data is corrupted, look at the program that allows data to be entered into the divno field. Make sure that there are sufficient data integrity controls at that point to ensure that the data is the type and format you're expecting. The Golden Rule of any database is to always validate data at time of data entry - there can never be an exception to this rule.
There's always a better way. The fun is trying to find it!