Want to update desire capabilities value dynamically in properties file

Hello,
We have requirement to update “download.default_directory” desire capability value in com.kms.katalon.core.webui.edge chromium.properties file which is there under “\settings\internal” folder path. Here is the desired capabilities that are placed in properties file,
{“EDGE_CHROMIUM_DRIVER”:{“ms:edgeChrominum”:true,“ms:edgeOptions”:{“prefs”:{“download.default_directory”:“D:\Download”,“download.directory_upgrade”:true,“download.prompt_for_download”:false,“plugins.always_open_pdf_externally”:true,“profile.default_content_settings.popups”:“0”,“profile.content_settings.exceptions.automatic_downloads.*.setting”:“1”},“args”:["–no-sandbox","–disable-dev-shm-usage"],“useAutomationExtension”:“false”}}}

So, we need replace “D:\Download” with string value that will be produced from our code. Tried using following code
file=new File(“C:\Kataloon\settings\internal\com.kms.katalon.core.webui.edge chromium.properties”)
Properties p=new Properties()
p.setProperty(“download.default_directory”, FileHelper.testFilesOutputFolderPathSanity)
FileOutputStream fos=null;
fos=new FileOutputStream(file);
p.store(fos, “Properties”);
fos.close();

But it is clearing whole file placing only “download.default_directory”: “generated dynamic path”

I am looking for a solution that only update the value of “download.default_directory” in the properties file. Thanks Inadvance