#!/usr/bin/perl -w use strict; my $line; my $maxline = 0; # make sure you get the length of the first line while($line = ) { chomp($line); print "$line\n"; $maxline = length($line) if length($line)>$maxline; $maxline -= 1 if $line =~ m/.*\032$/; } #----------------------------------------------- # using the char X to see it print a space based on maxline count # in this case it's 29 #----------------------------------------------- print "X" for (1..$maxline); print "\n"; __DATA__ This is my file it doesn't have a blank line at the end of it based on the maxline count of the file that it read.