Hello! I want to read entire file and then replace all \n with space. My sed script is (I know that it is not optimal but it demonstrates problem):

:a $! { N; ta }
s/\n/ /g
p

So why even with g flag s command replaces only first \n in pattern space? For instance I have the following file:

It was the best of times, it was
the worst of times, it
was the age of
wisdom,
it
was
the age
of foolishness,

The result of script execution is:

It was the best of times, it was the worst of times, it
was the age of wisdom,
it was

I use GNU sed 4.8. It seems to be a bug.