rewrite FindStringInBuffer to use an explicit loop instead of