#!/usr/bin/perl

use strict;

my(@headers) = @ARGV;

my($fetch);

while (<STDIN>) {
	if (1 ... /^\r?\n?$/) {
		$fetch = 0 if (($fetch) and !(/^\s\S/));
		foreach my $header (@headers) {
		    $fetch = 1 if (/^${header}:/);
		}
		print($_) if ($fetch);
	}
}
