title: Issue with substring replacement in Haskell
body: <p>I'm running into an odd issue with a small function written in Haskell which is meant to go through a string and replace a word within it with a different word. The function works when a small string is used, but when searching through large strings to replace the words strange things happen. The function is defined as follows:</p>
  
  <pre><code>swapwords :: String -&gt; String -&gt; String -&gt; String
  swapwords w1 w2 [] = []
  swapwords w1 w2 (x:xs)
      | length (x:xs) &lt; n = (x:xs)
      | otherwise = do     
      if w1 == take n (x:xs) then w2 ++ swapwords w1 w2 (drop n (x:xs))
          else x:swapwords w1 w2 xs
      where n = length w1 
  </code></pre>
  
  <p>When running with swapwords "ab" "ba" "ab" the output is correctly "ba", however when ran with the input "lamb" "buffalo" "Mary had a little lamb whose fleece was white as snow" the output still correctly swaps "lamb" with "buffalo", however added onto the end of the string is part of the messages first displayed when WinHugs is loaded, e.g "Mary had a little buffalo, whose fleece was white as snown -98 to enable exensions</p>
  
  <p>Type :? for help"</p>
  
  <p>As a relative notice to Haskell I have no idea why this is happening and would appreciate any input that could be given as to why this is occuring.</p>