in reply to printing 20 characters in a line.
hellow ....
your code needs some modifications ..
in your code if ($count/$align==1){print "\n"; $flag=1;}
it will print new line on terminal not in file.so change it with print OUT "\n";
if($flag==1){$count=0;}
after this line the value of $flag variable is always 1 so change it .....
One more thing define $flag & $count outside the for loop.
no need of $align. you can direct compare the $count == 20 .