title: Get some string before " not in all lines python
body: <p>I have such entries in a txt file with such structure:</p>
  
  <pre><code>Some sentence.
  Some other "other" sentence.
  Some other smth "other" sentence.
  </code></pre>
  
  <p>In original:</p>
  
  <pre><code>Камиш-Бурунський залізорудний комбінат
  Відкрите акціонерне товариство "Кар'єр мармуровий"
  Закрите акціонерне товариство "Кар'єр мармуровий"
  </code></pre>
  
  <p>I want to extract everything <strong>before "</strong> and write to another file. I want the result to be:</p>
  
  <pre><code>Some other
  Some other smth
  Відкрите акціонерне товариство
  Закрите акціонерне товариство
  </code></pre>
  
  <p>I have done this:</p>
  
  <pre><code>f=codecs.open('organization.txt','r+','utf-8')
  text=f.read()
  words_sp=text.split()
  for line in text:
      before_keyword, after_keyword = line.split(u'"',1)
      before_word=before_keyword.split()[0]
      encoded=before_word.encode('cp1251')
      print encoded
  </code></pre>
  
  <p>But it doesn't work since there is a file lines that doesn't have <strong>"</strong>. How can I improve my code to make it work?</p>