in reply to no output

Maybe you'd get warnings if you didn't disable them:

use strict; use warnings;
You try to print to XML but have opened it for reading. I suppose you meant OUT. You should add an argument to close, and maybe close all three handles.