The artist and song data are probably on different lines in the html code. To get both items on one line, you need to store the first item in a variable when it arrives, and then write both items at the same time when the second arrives. Here is a pseudocode example:

if (song isin thisdata) {
set %song $htmlfree($1-)
}
elseif (artist isin thisdata) {
write file.txt %song $htmlfree($1-)
}

-genius_at_work