#!/usr/bin/perl

# Skip the header, i.e. any non-empty line
while(<STDIN>) {
  last if /^\s*$/;
}

my $body = "";
my $separator = "";

# Begin the message with the subject line, if it exists
if (defined $ARGV[0]) {
  $body = $ARGV[0];
  $separator = " ";
}

# Then concatenate all other lines
while(<STDIN>) {
  chomp;
  if ($_ !~/^\s*$/) {
    $body .= $separator;
    $body .= $_;
    $separator = " ";
  }
}

