Incorporating feedback from @tanoku. Removed repeated strlen's, and unnecessary loop-termination variable.