Fix problems with empty fields at end of line
Make compatible with ruby 1.9 and higer

Should also fix problems mentioned in #1