You can either add an "there's a successfull read" condition to the "while N <= 10" statement you already have, or use the $lines identifier. I'd go for the first.
var %i = 1
while ((%i <= 10) && ($read(archives.txt,%i))) {
msg #channel $v1
inc %i
}
or e.g.
var %i = 1, %file = archives.txt, %max = $iif(($lines(%file) < 10),$v1,$v2)
while (%i <= %max) {
msg #channel $read(%file,%i)
inc %i
}
[ Pitty that for the -l switch of the /play command, there's no second parameter, like -l1-10
]