Fix IndexError raised by empty list at end of file

Per our discussion, this simply adds a check for empty rows and ignores them.