My bet is that you are running on a *nix platform and the
data in the database includes \r\n sequences. Therefore
when you display a line it displays the line, does a
carriage return, and then (since you don't do the newline
advance) displays the next line on top of the old.
Try stripping out \r and see if that makes a difference.