The bigger problem with your code is that you need to enclose the filename/dirname in quotes in order to have the full filename (or path) as the section in the ini file (due to spaces in files/paths).
Change:
writeini -n ini\songs.ini %file $user true
To:
writeini -n ini\songs.ini " $+ %file $+ " $user true
In this case, it is better to use individual $+ instances rather than using $+(), to avoid any problems caused by comma's in filenames or path's
Edit: we posted at the same time, but this answers your question. Updated to reflect your changes.