Fixed a double-null bug

Two nulls were being added to buf when multiple termination chars were sent from the PC