I am doing pos tagging using 'nltk' in Python and the code below works perfectly fine when I print it. 

```
import nltk 
import pos_tag
import nltk.tokenize 
import numpy

f = open(r'C:\Users\sample_data.txt')
data = f.readlines()

#Parse the text file for NER with POS Tagging
for line in data:
    tokens = nltk.word_tokenize(line)
    tagged = nltk.pos_tag(tokens)
    #print (tagged)

output = open(r"C:\Users\output3.csv", "w")
output.write(str(tagged))
f.close()

```

So when I print the code above, the output looks like this, which is exactly what I want. 

```
[('This', 'DT'), ('is', 'VBZ'), ('a', 'DT'), ('simple', 'JJ'), ('sentence', 'NN')]
[('I', 'PRP'), ('love', 'VBP'), ('this', 'DT'), ('company', 'NN'), ('.', '.'), ('This', 'DT'), ('company', 'NN'), ('is', 'VBZ'), ('so', 'RB'), ('good', 'JJ'), ('.', '.')]
[('I', 'PRP'), ('am', 'VBP'), ('not', 'RB'), ('inovlved', 'VBN'), ('with', 'IN'), ('this', 'DT'), ('work', 'NN'), ('.', '.'), ('So', 'RB'), ('hard', 'JJ'), ('!', '.')]
[('What', 'WP'), ('are', 'VBP'), ('you', 'PRP'), ('doing', 'VBG'), ('?', '.'), ('Are', 'NNP'), ('you', 'PRP'), ('nut', 'RB'), ('?', '.')]
[('Can', 'MD'), ('I', 'PRP'), ('borrow', 'VB'), ('your', 'PRP$'), ('jar', 'NN'), ('?', '.'), ('Just', 'NNP'), ('for', 'IN'), ('today', 'NN'), ('.', '.')]

```

But when I write it using the last three lines in the code, it saves only the last string in the text file (i.e.,[('Can', 'MD'), ('I', 'PRP'), ('borrow', 'VB'), ('your', 'PRP$'), ('jar', 'NN'), ('?', '.'), ('Just', 'NNP'), ('for', 'IN'), ('today', 'NN'), ('.', '.')]). 

I would like to save the entire results in txt or csv file, and one string in each [ ] should be saved in one line in txt or csv file. 

I am really really new to Python, so help will be appreciated.