title: getline() in C creating an infinite loop and skipping first word?
body: <p>I'm a beginner in C and I'm trying to create a simple todo list program. I'm trying to use getline in a while loop, as I saw on another stack overflow answer and I thought I understood it but it's just creating an infinite loop. Also it seems to be skipping the first word for some reason. Here is my code so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  FILE *list;
  int i = 0;
  int item = 0;
  char items[10];
  char chars[1000];
  char * line = NULL;
  size_t len = 0;
  ssize_t read;
  
  int main() {
    list = fopen("/Users/bendavies/Documents/C/list.txt", "r");
    int letterCount = fscanf(list,"%s",chars);
  
    printf("Welcome to the to-do list. It can hold up to 10 items.\n");
  
    printf("%d\n", letterCount);
  
    if (letterCount == -1) {
      printf("The list currently has no items!\n");
    } else {
        while ((read = getline(&amp;line, &amp;len, list)) != 1) {
          item += 1;
          printf("%d. %s", item, line);
        }
      }
      fclose(list);
  
    return 0;
  }
  </code></pre>
  
  <p>The output I'm currently getting with the following list.txt:</p>
  
  <pre><code>Eat food
  Drink water
  Breath air
  </code></pre>
  
  <p>Is:</p>
  
  <pre><code>1.  food
  2. Drink water
  3. Breath air
  4. 18446744073709551615
  5. 18446744073709551615
  </code></pre>
  
  <p>and so on and so forth.</p>
  
  <p>Thank you in advance! :)</p>