In the worst case you will get garbage. That's why there are functions to lock files or even parts of files. Basically every script tries to lock a file for itself, if that fails it waits and tries again. Whoever has the lock writes to the file and then releases the lock.