RTFM - The API docs state that calling this method writes the comment followed by a comment line containing the date followed by the properties data.

Your empty file problem is that you are calling this method on an empty properties file and then adding the data on subsequent lines.

I'm not sure that using a properties object is the best way to read and write an ini file. It is designed to handle key-value pairs and has no concept of the heading/sections used in ini files to segregate data