Better logging

If you're going to keep repeating this pattern, you might consider generalizing the code to a new stream type that encapsulates the behavior.