- `mutex` serves no purpose. It is not shared between processes, and your program is not multithreaded. If you want an exclusion between unrelated instances of the program, you need to place it in a named shared memory segment (see [example](https://man7.org/linux/man-pages/man3/shm_open.3.html#EXAMPLES)). - >// Don't need any semaphores here - writing processes write to a temp file then rename so no issues with reading Not so. Process `P1` writes to `temp1`. Meanwhile, process `P2` writes to `temp2`. After renaming, one of the edits is lost. - The line index = fopen("index.bin", "r"); at the end of `addIndexLine` has no effect. The caller still has the original file pointer. BTW, after the call to `addIndexLin` the pointed file is closed, and cannot be used by a caller anymore. Doesn't look promising. - `remove("data.bin")` is superfluous. Just `rename` works as well. - Don't spell out the program name in the help/error messages. Use `argv[0]`. - `const`-qualification of arguments is sorely missing. - Don't spell out the program name in the help/error messages. Use `argv[0]`. - `compareString`... What's wrong with `strncmp`? PS: I didn't dig deep into the design of the DB files. To be honest, I was quickly lost.