Clear buffer after each write

Should fix issue #1