diff --git a/bittide-instances/src/Project/Handle.hs b/bittide-instances/src/Project/Handle.hs index ff0b07d89..6ad7e5b4d 100644 --- a/bittide-instances/src/Project/Handle.hs +++ b/bittide-instances/src/Project/Handle.hs @@ -46,9 +46,11 @@ waitForLine h expected = -- Utility function that returns the remaining characters in a handle. readRemainingChars :: Handle -> IO String readRemainingChars h = do - rdy <- hReady h - if rdy - then do - c <- hGetChar h - (c :) <$> readRemainingChars h - else (pure "") + eof <- hIsEOF h + if eof then pure "" else do + rdy <- hReady h + if rdy + then do + c <- hGetChar h + (c :) <$> readRemainingChars h + else pure ""