Alright

So first, I apologize for missing all these things before. I have quite a bit of a headache so my focus isn't as good as it could be.

That said, I'd assume that you would want each song to play once the previous is finished, rather than all at once like the while loop will do... If so, you can create an alias which uses a timer that calls itself after a certain number of seconds (say, the length of the song) if there are any more songs to play, and then just call that alias from the on TEXT event... Based on your current code for example:

Code:
alias -l playYT {
  var %file = songrequest.ini
  if (!$ini(%file, 0)) return
  ; -----------------------------------------
  var %song = $ini(%file, 1)
  url -a www.youtube.com/watch?v= $+ %song
  remini %file %song
  .timerplayYT 1 $ini(%file, %song, 1) playYT
}

on *:TEXT:!play &:#:{
  if ($2 == start) playYT
}


The alias above will first check if there are no songs left in the file (via $ini(songrequest.ini, 0)), and, if so, return and do nothing, otherwise, open the youtube video in browser for the first song, remove that song from the file, then start a timer that (hopefully) takes the song's play time as a delay and repeats the whole process again while applicable. As a bonus, this timer method eliminates the need for a global variable and -z switch for your script.

Though I am curious... how exactly is the ini file structured? because $ini(%file, %song, 1) will return the first item name (part left of the =) rather than its value... So this appears wrong to me but maybe you've written it that way for some reason.