My apologies -- I read the OP too hastily.
Again, will scp do the trick?
You are trying to use the $after_match to grab everything after a match. This is not the way Expect works. It will only read what it needs in order to match the pattern you specified. You need to match the end of the file and then take everything before the end.
#untested
my $prompt = "my_unique_custom_prompt_aint_it_neat>";
$object->send("export PS1=$prompt\r");
$object->expect(10, $prompt);
$object->send("cat file.txt\r");
$object->expect(10, $header);
$object->expect(120, $prompt);
my $contents = $object->before();