please add code tags to your post

are you trying to append the data to an existing text file or create a new one?