minor fix to writeTCP