Move stdout capture to a rule