Changed from strlen to using size() as pointed out by Kjetil.