Thanks for taking a look jcl. I applied your fix and the script is now extracting the values perfectly.

Thanks also for the tip about the printf statement. I actually did do this but still couldn't figure what the error was. I'm such a noob.