Fix total written bug in socket_writeline().