Writing to stdout logic was duplicated.