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(":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 would produce by default, but all within the Message rendering.

>>>"sleep 1; echo Hello; sleep 1; echo World", shell=True,
│ 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?