title: scanUpToCharactersFromSet stops after one loop
body: <p>I'm trying to get the contents of a CSV file into an array. When I've done this before I had one record per line, and used the newline character with <code>scanUpToCharactersFromSet:intoString:</code>, passing <code>newlineCharacterSet</code> as the character set:</p>
  
  <pre><code>while ([lineScanner scanUpToCharactersFromSet:[NSCharacterSet newlineCharacterSet] 
                                     intoString:&amp;line])
  </code></pre>
  
  <p>Now, I'm working with a file where many of the entries themselves contain newline characters. I've tried adding a unique character to the end of each record (a <code>*</code> character) but my loop only runs once. Is there something which is making the while loop break that I don't know about? Here's the code I'm using now:</p>
  
  <pre><code>NSError *error;
  NSString *data = [[NSString alloc] initWithContentsOfFile:[[self delegate] filePath] encoding:NSUTF8StringEncoding error:&amp;error];
  NSScanner *lineScanner = [NSScanner scannerWithString:data];
  NSString *line = nil;
  
  // Start parsing the CSV file
  while ([lineScanner scanUpToCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@"*"]
                      intoString:&amp;line]) {
      NSArray *elements = [line componentsSeparatedByString:@","];
      NSLog("Name: %@", [elements objectAtIndex:1]);
  }
  </code></pre>
  
  <p>**Edit: ** Thanks to Peter's answer below, I found that my scanner was stuck behind the * character. I added this line in the loop:</p>
  
  <pre><code>[lineScanner scanCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@"*"] intoString:NULL];
  </code></pre>
  
  <p>and now it's working like it should.</p>