<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Bill,<br><br>Each quote of the input is on a single line. I want to unwrap lines greater than 72 characters, i.e., break them into several lines each &lt;= 72 characters, but I don't want to break up words. and I want to retain the blank lines. So, my output is correct except for the error message.<br><br>Michael <br><br>============ My input data ============<br>However mean your life is, meet it and live it: do not shun it and call it hard names. Cultivate poverty like a garden herb, like sage. Do not trouble yourself much to get new things, whether clothes or friends. Things do not change, we change. Sell your clothes and keep your thoughts. God will see that you do want society.<br><br>Men have become the tools of their tools.<br><br>I know of no more encouraging fact than the unquestioned ability of a man to elevate his life by conscious
 endeavor.<br><br>I once had a sparrow alight upon my shoulder for a moment, while I was hoeing in a village garden, and I felt that I was more distinguished by that circumstance that I should have been by any epaulet I could have worn.<br><br>-Thoreau<br>============ My output ============<br>unwrap: &lt;stdin&gt;: hGetLine: end of file&nbsp; &lt;&lt;&lt;&lt; here's my eof message<br>However mean your life is, meet it and live it: do not shun it and call <br>it hard names. Cultivate poverty like a garden herb, like sage. Do not <br>trouble yourself much to get new things, whether clothes or friends. <br>Things do not change, we change. Sell your clothes and keep your <br>thoughts. God will see that you do want society.<br><br>Men have become the tools of their tools.<br><br>I know of no more encouraging fact than the unquestioned ability of a <br>man to elevate his life by conscious endeavor.<br><br>I once had a sparrow alight upon my shoulder for a
 moment, while I was <br>hoeing in a village garden, and I felt that I was more distinguished by <br>that circumstance that I should have been by any epaulet I could have <br>worn.<br><br>-Thoreau<br>============ Your output ==========<br>However mean your life is, meet it and live it: do not shun it and call <br>it hard names. Cultivate poverty like a garden herb, like sage. Do not t<br>rouble yourself much to get new things, whether clothes or friends. Thin<br>gs do not change, we change. Sell your clothes and keep your thoughts. G<br>od will see that you do want society.<br>Men have become the tools of their tools.<br>I know of no more encouraging fact than the unquestioned ability of a ma<br>n to elevate his life by conscious endeavor.<br>I once had a sparrow alight upon my shoulder for a moment, while I was h<br>oeing in a village garden, and I felt that I was more distinguished by t<br>hat circumstance that I should have been by any epaulet I could
 have wor<br>n.<br>-Thoreau<br>===================================<br><br><br>--- On <b>Fri, 8/13/10, Bill Atkins <i>&lt;watkins@alum.rpi.edu&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Bill Atkins &lt;watkins@alum.rpi.edu&gt;<br>Subject: Re: [Haskell-cafe] Unwrapping long lines in text files<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: haskell-cafe@haskell.org<br>Date: Friday, August 13, 2010, 11:13 PM<br><br><div class="plainMail">Not sure if I understood what you're trying to do, but development will be easier if you minimize your IO, e.g. :<br><br>maxLineLength :: Int<br>maxLineLength = 72<br><br>wrapLine :: String -&gt; [String]<br>wrapLine "" = []<br>wrapLine line <br>&nbsp; | length line &lt;= maxLineLength&nbsp; &nbsp; = [line]<br>&nbsp; | otherwise&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = take maxLineLength line : wrapLine (drop maxLineLength line)<br><br>main :: IO ()<br>main = interact $ unlines . concatMap wrapLine . lines<br><br>Now wrapLine is pure and you can use it more easily using GHCi.&nbsp; Removing dependencies on IO usually makes your problem easier to test and understand and your code simpler.<br><br>In your example, the EOF probably happens on the call to getLine after input has run out.&nbsp; By using Prelude.interact, we can ignore details like that and rely on already-written functions.<br><br>HTH,<br>Bill<br><br>On Friday Aug 13, 2010, at 9:38 PM, michael rice wrote:<br><br>&gt; The program below takes a text file and unwraps all lines to 72 columns, but I'm getting an end of file message at the top of my output.<br>&gt; <br>&gt; How do I lose the EOF?<br>&gt; <br>&gt; Michael<br>&gt; <br>&gt; <br>&gt; ====== unwrap.hs ======<br>&gt; <br>&gt; main = do<br>&gt;&nbsp;
 &nbsp;&nbsp;&nbsp;line &lt;- getLine<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;if null line<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;then do<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putStrLn ""<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; main<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;else<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printList (words line) 1<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; main<br>&gt; <br>&gt; <br>&gt; printList :: [String] -&gt; Int -&gt; IO ()<br>&gt; printList [] _ = do putStrLn ""<br>&gt; printList (w:[]) k = do <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if k+(length w) &lt;= 72<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; then do<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; putStrLn w<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else do<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putStrLn ""<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putStrLn w<br>&gt; printList r@(w:ws) k = do <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if k+(length w) &lt;= 72<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; then do<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putStr w<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putStr " "<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printList ws (k+(length w)+1)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else do<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putStrLn ""<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printList r 1<br>&gt; <br>&gt; <br>&gt; <br>&gt; _______________________________________________<br>&gt; Haskell-Cafe mailing list<br>&gt; <a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br><br></div></blockquote></td></tr></table><br>