Fix the number of written bytes to the tty

Signed-off-by: Tomas Hozza <thozza@gmail.com>