XYZ
XYZ

Reputation: 23

haskell putStr outputs extra newlines

main = do
       file_name <- getLine
       text <- readFile file_name
       let b = prepare $ line text
       let x = sth b
       mapM_ (putStr . print_matrix . fst ) x

When I ran this code I got:

1 2 3

4 5 6

7 8 9

9 2 1

1 1 1

1 1 1

But in random lines I got extra newlines. When I wrote 300 lines I got 2 extra random newlines.

9 2 1

(extra enter)

1 1 1

1 1 1

Upvotes: 0

Views: 409

Answers (1)

clintm
clintm

Reputation: 1259

I'm pretty sure putStr is printing the newlines read in from the file, unless prepare or sth is chopping them off.

Upvotes: 1

Related Questions