title: Stripping newlines from fread
body: <p>I'm loading a file using this code, but it seems like removing the newlines also for some reason removes all lines but the first.</p>
  
  <pre><code>void load_script(char* path) {
      FILE* file;
      char* script;
      int filesize = 0;
  
      file = fopen(path, "r");
  
      // determine file size
      fseek(file, 0L, SEEK_END);
      filesize = ftell(file);
      fseek(file, 0L, SEEK_SET);
  
      // allocate memory
      script = malloc(filesize + 1);
  
      // read script
      size_t size = fread(script, 1, filesize, file);
      script[size] = 0;
  
      printf("Before stripping:\n%s\n", script);
  
      // strip newlines
      script[strcspn(script, "\n")] = 0;
  
      printf("After stripping:\n%s\n", script);
  
      fclose(file);
      tokenize(script);
  }
  </code></pre>
  
  <p>Here's the output:</p>
  
  <pre><code>Before stripping:
  line 1
  line 2
  line 3
  After stripping:
  line 1
  </code></pre>
  
  <p>I'd love to know the best way to strip newlines from a multiline string. Thanks.</p>