Improve implementation of puts().