Answer
Use Address_Presentation_API.Format_Address, passing the country and the individual address-line fields, rather than concatenating the raw address fields yourself — this function applies the same per-country formatting rules configured on the Address Presentation page (the ones the standard client already uses), which correctly skips blank lines instead of leaving gaps where an address field happens to be empty.