SanitizeTextFiles: faster, more readable, and slightly more correct