Write database in binary mode to ensure '\n' line endings on Windows