As the replies you've already had hint, but perhaps don't make explicit enough, white space (including line breaks, tabs, spaces, etc.) is special in HTML in that it is largely ignored. In general any amount of adjacent white space in HTML can be replaced with a single space. HTML is not an appropriate way to store information that depends on white space for interpretation!
Where does the HTML you are trying to process come from? It would be better to either structure the data in a table if you must use HTML, or use a format appropriate to managing the data such as csv.
True laziness is hard work