How to identify and remove newline and white spaces?
To remove all extra space and \n from your string-
NSString* result = [yourString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
than prepare your contentsOfFile Array.
If you want an array without whitespace:
NSString *string = @"Hello, World!";
NSCharacterSet *separator = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSArray *stringComponents = [string componentsSeparatedByCharactersInSet:separator];
stringByTrimmingCharachersInSet:
only removes desired characters from the end and the beginning of the string. To remove all occurences you should use stringByReplacingOccurrencesOfString: