parse empty last line as Nil
refactoring
change empty line handling
refactoring