title: Haskell Parsec EOF
body: <p>I have a file containing many of the following data format:</p>
  
  <pre><code>Dan Clark’s Profile Photo
  Member Name
  Dan Clark  2nd degree connection 2nd
  Member Occupation
  Founder and Headmaster at Some Company, LLC
  Nina blalba’s Profile Photo
  Member Name
  Nina blabla  2nd degree connection 2nd
  Member Occupation
  Consultant - GAmes executive search
  </code></pre>
  
  <p>My parser to parse the above file:</p>
  
  <pre><code>module Main where
  
  import           Control.Applicative
  import           Control.Monad
  import           Text.ParserCombinators.Parsec hiding (many, (&lt;|&gt;))
  
  data Contact = Contact {
    name :: String,
    occupation :: String,
    company :: String
  
                         } deriving Show
  
  matchContact :: Parser Contact
  matchContact = do
    name &lt;- many anyChar
    char '\''
    string "s Profile Photo"
    char '\n'
    string "Member Name"
    char '\n'
    string name
    many anyChar
    char '\n'
    string "Member Occupation"
    char '\n'
    job &lt;- many anyChar
    try $ string " at "
    company &lt;- many anyChar
    try (char '\n')
    return $ Contact name job company
  
  main = do
    c &lt;- parseFromFile (many matchContact &lt;* eof) "contacts.txt"
    print c
  </code></pre>
  
  <p>There are many issues such as the data are not regular. But the most urgent one is that I always run into the error at the last line of the input file:</p>
  
  <pre><code>Left "contacts.txt" (line 8670, column 12):
  unexpected end of input
  expecting "'"
  </code></pre>
  
  <p>How to fix this?</p>