There must be something different in the way the files are opened in the 2 programs that cause an error. Are you opening the file with an index tag name like "USE MYFIILE IN 0 ORDER TAG1" ?
Be that as it may... it's not good programming practice to erase index files. Why do you need to erase index files? The only time they should be erased is when you have a reason to suspect that they have become corrupted or damaged, and then they should be removed by the "DELETE TAG ALL" method above, followed immediately by a series of commands to rebuild them (i.e. INDEX ON TRANDATE TAG TRANDATE, etc.)
Steve