I am using the following code to write in a file.
fileName = [[NSBundle mainBundle] pathForResource: @"user" ofType: @"txt"];
NSFileHandle *myHandle = [NSFileHandle fileHandleForUpdatingAtPath:fileName];
[myHandle seekToEndOfFile];
NSData *dataName = [uname dataUsingEncoding: NSUnicodeStringEncoding];
if ([dataName writeToFile:fileName atomically:YES])
NSLog(@"writeok");
[myHandle seekToEndOfFile];
It overwrites the file. Suppose the file already contains the string "box". Now when I write a new word, "Hello", then the file contains only "Hello", not "box".
What is the problem with the code?