Create an empty data record with a java component

I need to create a Pipeline Pilot java component which writes out the content of a specific file. So there are two questions:

Since I do not have a input port allowed on the component in this case, it is not clear if this should be done with onInitialize() method or onProcess() method.

The next question is, how can I create an empty data record, this did not work for me (using onInitialize(Context cntxt)):

DataRecord dr = cntxt.createDataRecord();

PropertyCollection collection = dr.getProperties();

in the 2nd row I get an error: The data record has no contents.

Can you please help me, how this should be done?