I'm working on cgi+bash script. I am unable to print the contents of a file in proper format on webpage i.e. with proper line breaks.

The snippet below has provided me only 60% success (some of lines were display as expected and the other were combined with previous line). I would like to know if there is anyway that I can
provide "visible" line breaks on the webpage while displaying the content. Or if possible add a line (-------------------)
after every newline.

 NO_OF_LINES=`wc -l filename | cut -d' ' -f1`
                for i in `seq 1 $NO_OF_LINES`;
                      LINE=`cat filename | sed -n "$i s/\(^[A-Z]\|.*\)/\1/p" | sed 'G;G'`
                      echo "$LINE"
the file starts with few letters in CAPS then '|' sign, hence i have used ^[A-Z]\.

any help would be appreciated.