When pd is started with -nogui or -batch, [writesf~] seems not able to produce a soundfile with content, when 'dsp 1' message is sent on loadbang. In -nogui mode, this can be worked around by using a [delay 0] before triggering the 'dsp 1'-message to 'pd'. In -batch mode, even this doesn't work. The only way i could find to effectively delay the 'dsp 1' message was to use -send 'pd dsp 1' from commandline, when launching Pd.
Also it's only possible to create proper soundfiles, if the 'open' message for [writesf~] is sent after the 'dsp 1' to pd. This can render the use of [writesf~] in -batch mode quite troublesome, especially when wanting to use pre-existing patches.