open my $FH, '>', 'results' or die $!; while (my $bytes = xbee_get_bytes()) { print $FH $bytes; }