Pipe unix commands to elixir cli

Hello everyone,

Should the first funciton return the same result as the second one? What am i missing here?
mix escript.build && cat test.txt | ./ccwc -l

mix escript.build && ./ccwc -l test.txt

EDIT:

String.split gives one too many elements for me:

iex(4)> StringIO.open("abc\n\n\n", fn pid -> IO.stream(pid, :line) |> Enum.to_list() end)
{:ok, ["abc\n", "\n", "\n"]}

iex(5)> StringIO.open("abc\n\n\n", fn pid -> IO.read(pid, :all) |> String.split("\n") end)
{:ok, ["abc", "", "", ""]}

I couldn’t reproduce the 7152 result with the test.txt from your previous post, but I’m on an older Elixir version…


Side-note: using triple-backticks to format code (```) will make it easier for future readers to find this code when searching vs screenshots.