in reply to Text file got corrupted?
I think your simultaneous access theory is probably correct. The cure is flock, which is not always easy to get right. Read the docs and search here for working examples.
After Compline,Zaxo