The -1 is because you included the '\n'; better to skip the '\n' in the count, see above.