sleep the difference between 1000ms and time spent writing

It's unnecessary to wait the full second, instead we can use the above
formula to sleep more efficiently. h/t @ztellman for pointing this out
and gisting up a change!