Looks ok except for some reason the IFS as a newline does not seem to be working. Another method would be to use the standard bash argument variables and iterate through the list with a shift