End of Line in Shell Scripting

I have a file containing records seperated by delimiter '|'.A record is contained on 2 or 3 lines. Now I need a shell script which could write all records with in two '|' character in one line.....for example.....

|R1........................R1
R1..........................R1
........R1|R2.............R2
R2......|R3..................
R3...........................R3
R3....................|R4.....

I want output as :
R1.............R1 (end of line)
R2...................R2 (end of line)
R3...R3 (end of line)
R4...............(end of line)
.....all on single lines no matter original record is in 2 lines or more or less......

Pls help in this regard.Thanks.

I am using this function to convert pipeline | to end of line (\n), but it is just writing n in the output:

sed 's/|/\n/' input_file > output_file

awk 'BEGIN {FS="\n" ; OFS=""; RS="|" } $1=$1' input_file > output_file

If you get syntax errors try nawk instead of awk.

thanks a lot it is really working with nawk......but can u pls explain in one or two line about it.....thanks.