Dont indicate end of transmission if it won't end
Factor out stripping of newlines
Factor out communication in its own function set

While here fix whitespaces in tools.c