You are mixing 2 things. First the program prints the string with the io:format/2 function. As there is no new line at the end of the string, the cursor in the shell stays at the same place. Then the function send(X,Name) returns its value, that is the result of the if statement, so the message itself: 0 and add a new line before printing the prompt.
The 2 things are independent so it is possible that you get:
0I'm about to send: 0
(pz@Molly)4>
or:
0
I'm about to send: 0(pz@Molly)4>
I am not sure of the order.
If you comment the io:format lite, you will see a single 0 remaining, or if you add a new line to the send function like
end,
ok.
the second 0 will be replaced by ok.