ruby: how to use IO#sync