title: I am trying extract a column of reviews from a dataset and storing in a file. Now I want to lemmatize this file into new file of lemmatized sentences
body: <pre><code>    *lemmatizing this file into a new file of sentences*
      
      *#reviewtext.txt - contains all the reviews from a column of database
      #And I am trying to store the lemmatized sentences into lemma file*
      
      #storing the column values into &quot;reviews&quot;
    
  
  reviews = df[df.columns[10]]
  
  #write a file containing raw reviews
  with open(&quot;reviewtext.txt&quot;, &quot;w&quot;) as f:
    f.write(&quot;\n&quot;.join(reviews))
  
  #creating a new file to store the lemmatized sentences
  lemma_file = open(&quot;lemma_reviewtext.txt&quot;,&quot;w&quot;)
  
  #initialize the Wordnet Lemamtizer
  lemmatizer = WordNetLemmatizer()
  
  file1 = open('reviewtext.txt','r')
  lines = file1.readlines()
  
  for line in lines:
    word_list = nltk.word_tokenize(line)
    lemmatized = ' '.join([lemmatizer.lemmatize(w) for w in word_list])
    lemma_file.write(&quot;\n&quot;.join(lemmatized))
  </code></pre>
  <p>Even though I am writing the lemmatized sentences to the lemmatized file, the file is still being empty. I am not sure where am I going wrong. Any suggestions please!</p>