   end
 
   defp state_after_read(%{capture_prompt: true, output: output} = state, remainder, prompt, count) do
-    %{state | input: remainder, output: <<output::binary, :binary.copy(IO.chardata_to_string(prompt), count)::binary>>}
+    output = <<output::binary, :binary.copy(IO.chardata_to_string(prompt), count)::binary>>
+    %{state | input: remainder, output: output}
   end
 
   defp bytes_until_eol("", _, count), do: {:split, count}

    case :unicode.characters_to_binary(chars, encoding, :unicode) do
      string when is_binary(string) ->
        {:ok, %{state | output: output <> string}}
      {_, _, _} ->
        {{:error, req}, state}
    end

        case apply(mod, fun, [continuation, binary_to_list(line, encoding) | args]) do
          {:done, result, :eof} ->
            {result, rest, count + 1}

          {:done, result, extra} ->
            {result, extra ++ binary_to_list(rest, encoding), count + 1}

          {:more, next_continuation} ->
            get_until(rest, encoding, mod, fun, args, next_continuation, count + 1)
        end
