How can I overload `IO` to perform an action on every line?

I’m writing a class to print a Julia-styled “markdown admonition” using rich.

>>> rich.print(Message.info(":rocket: Hi there!"))
│ Info
│ 
│ 🚀 Hi there!

My end goal is to use this style for a rich wrapper around subprocess. The image in my head is a live rendered output while a command is executing, just like subprocess.run would produce by default, but all within the Message rendering.

>>> subprocess.run("sleep 1; echo Hello; sleep 1; echo World", shell=True, stdout=Message.io())
│ Executing: sleep 1; echo Hello; sleep 1; echo World
│ 
│ Hello
│ World

I’ve never implemented any streams with Python before. I think the best way to do this would be to inherit from IO, and overwrite write to call some method that adds a line to the output (Message.update).

Is this a sensible solution?