in reply to file reading / writing collisions

This is usually done with flock. You want to get a shared lock for reading (which means you can have any number of processes reading the file at once) and an exclusive lock for writing (which means no other process can read or write at the same time).