I'm writing a command to deal with bacteria names. They're written in full the first time, then with just the first name and a period following it. I've managed what I have by cobbling together others' examples, though I seem to have an extra space. I'm ignoring for now that sometimes the second name is shortened as well.
MWE
\documentclass[letterpaper,10pt]{scrartcl}
\usepackage{etoolbox}
\def\splitfirstchar#1#2\sentinel{#1.}
\newcommand{\first}[1]{\splitfirstchar#1\sentinel}
\def\testwords#1{%
\readwords#1\relax
}
\def\readwords#1 #2\relax{%
\ifcsundef{bactused}{
\def\bactused{true}%want full name
\textit{#1 #2}
}{
\textit{\first{#1} #2}
}
%\relax
}
\def\ecoli{\testwords{Escherichia coli}}
\begin{document}
\ecoli
\ecoli\ecoli. Blah
\end{document}
Produces:

So where is the extra space coming from?