in reply to Adding to variable with sprintf()

Just so you know, the reason your code didn't work was because the line
$new_page_data = sprintf("%-5s", $line);
should have been
$new_page_data .= sprintf("%-5s", $line);