Factor out hdrline generation into a function of its own.