I am new to Ruby and am trying to write a simple program that reads a
text file, counts the number of paragraphs, and processes each one.
The Pickaxe book states:

   "ios.gets( aSepString=$/ ) -> aString or nil  
 
   Reads the next ``line'' from the I/O stream; lines are separated by
   aSepString. A separator of nil reads the entire contents, and a
   zero-length separator reads the input a paragraph at a time (two
   successive newlines in the input separate paragraphs). "

I haven't been able to get this to work using Ruby v1.6.5 on Windows
2000.   Not sure what is meant by "zero-length separator".

I tried this:
  pCnt = 0
  fn = 'c:\temp\work.txt'
  f = File.new(fn, "r")
  f.gets("") {|p|
    pCnt += 1
    puts p
  }
  print('Paragraph count = ', pCnt,"\n")

Where c:\temp\work.txt contained:
1a
1b
1c

2a
2b
2c

Result was: Paragraph count = 0
Interestingly, in irb, the first paragraph is written but not counted.
The second paragraph is ignored.
Could someone show me a working example?  Thanks in advance.

- James Davis -