2 things.
1. You set %query as a local var, so it wont be available in the sockopen event
you should /set it (global) and unset at the end of sockopen event
2. these lines
while ( $sockbr != 0 ) { aline @lyrics %' }
sockclose $sockname
should be more like
while ( $sockbr ) {
if $nohtml(%') { aline @lyrics $v1 }
[color:blue]sockread %'[/color]
}
(no need for /sockclose, it will be closed anyway

EDIT:
Make that 3 things..

var %temp %artist $+ $chr(32) $+ %title
shouldnt have a $chr(32) between the vars, no need for %temp anyway
set %query $replace($+(%artist,%title),$chr(32),$(%20,0))