title: Filter file by length BEFORE saving haskell
body: <p>A similar question has been asked, but with a list in hand:
  <a href="https://stackoverflow.com/questions/21410293">Filter list items by length in Haskell</a></p>
  
  <p>I already know how to get a word list from a file</p>
  
  <pre><code>getWords path = do contents &lt;- readFile path
                     return (lines contents)
  </code></pre>
  
  <p>And then I can filter it to get words of specific length, but...</p>
  
  <p>What I am wondering is if there is a way (preferably not in point-free style - unless necessary) to filter the file by length <strong>before</strong> saving it as a list of words.</p>
  
  <p>For example, words.txt is file of words with 1 word per line.</p>
  
  <pre><code>filteredWords &lt;- filter (\x -&gt; length x == 3) *Read words.txt in place*
  </code></pre>