sfd: stop outputting trailing whitespaces or double-spaces

r? @frank-trampe
@frank-trampe Do you think it's fine to add a space here after `~`? It does so on the other branch of the if but I'm not sure one is needed here too.