this is a rather convoluted way of doing it, you should just use shnsplit which can do it all in one go https://wiki.archlinux.org/title/CUE_Splitting