title: File write with [NSBundle mainBundle] fails
body: <p>I am trying to take content from one file and write it into another. I am reading fine, but I am not able to write it into another file.</p>
  
  <p>I have a database of words. I want to separate the words into different files based on the number of letters. All four letter words go into one file, and so on. I added a txt file called "4letter" into my resources and the following is my code:</p>
  
  <pre><code>NSError *error;
  
  //READ
  NSString *dbFile = [[NSBundle mainBundle] pathForResource:@"words" ofType:@"txt"];
  NSString *test = [NSString stringWithContentsOfFile:dbFile encoding:NSUTF8StringEncoding error:&amp;error];
  
  //convert from string to array
  NSArray *lines = [test componentsSeparatedByString:@"\n"]; 
  
  NSFileHandle *logFile = nil;
  logFile = [NSFileHandle fileHandleForWritingAtPath:[[NSBundle mainBundle] pathForResource:@"4letter" ofType:@"txt"]];
  
  //Test if write works
  for (int i=0; i&lt;5; i++) 
  {
      NSString *randomAnagram = [[lines objectAtIndex:i] lowercaseString];
      [logFile writeData: [randomAnagram dataUsingEncoding: NSNEXTSTEPStringEncoding]];
  }
  </code></pre>