replace a newline (\n)

dear all:
maybe i have a file like :
12

34

56
78
end

how do write can i replace newline into NA :
make the file inte :
12
NA
34
NA
56
78
END

I wrote a shell like:
foreach a (fiel){
if a == ""
set $a=NA
}
but can't work maybe someone can help me

sed s/^$/NA/g file

you can always redirect the o/p to a new-file.

-ilan

using Perl:

perl -pi -e 's/^$/NA/' filename

Thanks all,
both work well,