When Keypirinha writes the .catalog or .history file, it should use the "swap method" by first creating a file with a different name, generating its content and fully writing it. Only then, the original file is overwritten with the new content (i.e. move operation).
This limits the risk of having corrupted data in case writing is interrupted.
Ref: initial chat