Account for \0 and optimise a little