I'm no expert with sed, but if it is a problem with white space you could try updating the sed command to also call the tr command as follows to remove space from either end of DATE and GENRE.
DATE=`sed -n 's!^REM DATE "\?\([^"]*\)"\?!\1!p' "$cue_file" | tr -d '[:space:]'` GENRE=`sed -n 's!^REM GENRE "\?\([^"]*\)"\?!\1!p' "$cue_file" | tr -d '[:space:]'`
I'm no expert with sed, but if it is a problem with white space you could try updating the sed command to also call the tr command as follows to remove space from either end of DATE and GENRE.
DATE=`sed -n 's!^REM DATE "\?\([^ "]*\)"\ ?!\1!p' "$cue_file" | tr -d '[:space:]'` "]*\)"\ ?!\1!p' "$cue_file" | tr -d '[:space:]'`
GENRE=`sed -n 's!^REM GENRE "\?\([^