Haskell program will not end if input = 0

When the user inputs number m = 0, the program will never stop counting. Is there any way how to take care of that? so if the user inputs 0 the program will end.    

    import Control.Monad (replicateM)

    transpose :: [[a]]->[[a]]
    transpose ([]:_) = []
    transpose x = (map head x) : transpose (map tail x)

    readMany :: Read a => IO [a]
    readMany = fmap (map read . words) getLine

    formatMatrix :: [[Int]] -> String
    formatMatrix = unlines . map unwords . map (map show)

    parse :: IO ([[Int]])
    parse = do
			[n] <- readMany
			matrix <- replicateM n readMany
			return (matrix)

    main :: IO ()
    main = do	  
			  matrix <- parse
			  let tMatrix = transpose matrix
			  putStrLn "\n"
			  putStr (formatMatrix tMatrix)


Haskell program will not end if input = 0
===


When the user inputs number m = 0, the program will never stop counting. Is there any way how to take care of that? so if the user inputs 0 the program will end.    

    import Control.Monad (replicateM)

    transpose :: [[a]]->[[a]]
    transpose ([]:_) = []
    transpose x = (map head x) : transpose (map tail x)

    readMany :: Read a => IO [a]
    readMany = fmap (map read . words) getLine

    formatMatrix :: [[Int]] -> String
    formatMatrix = unlines . map unwords . map (map show)

    parse :: IO ([[Int]])
    parse = do
			[n] <- readMany
			matrix <- replicateM n readMany
			return (matrix)

    main :: IO ()
    main = do	  
			  matrix <- parse
			  let tMatrix = transpose matrix
			  putStrLn "\n"
			  putStr (formatMatrix tMatrix)

