Source: https://www.cs.unm.edu/~joel/cs241/note/CS-241-Lecture-09-CountingCharactersLinesAndWords.pdf