Why do you subtract `2`? Please add a comment explaining this. However, I believe that you only need to account for the null byte.