[Solved] Break a tcolorbox and remove subsequent empty lines

Cactus Asks: Break a tcolorbox and remove subsequent empty lines
I have some lstlisting blocks that I am typesetting as colored textboxes. Some of these blocks contain empty lines; and some of these blocks are broken across page boundaries by a manual tcbbreak. I would like to replace the tcbbreak command with another command that issues a tcbbreak and then removes any subsequent empty lines (even better would be removing any subsequent lines that only consist of whitespace, but I can preprocess my files to make sure all whitespace-only lines are empty).

Code:
documentclass{article}

usepackage{listings}
lstset{escapeinside=!!}
  
usepackage[breakable,listings]{tcolorbox}
renewtcblisting{lstlisting}{breakable,listing only}

begin{document}
begin{lstlisting}
  Lines of text
  Inside a TColorBox

  Burma Shave
end{lstlisting}

begin{lstlisting}
  Lines of text
  Inside a TColorBox !tcbbreak!
  
  Burma Shave
end{lstlisting}

end{document}

And before anyone recommends the obvious (“just delete the empty file from the source when you put in the tcbbreak“), for my real use case I will need to use the same source both for paginated output (where the breaks should be there and should gobble up subsequent empty lines) and non-paginated output (where the breaks should not be there and the empty lines should be left intact).

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.