Handle empty lines gracefully

Partially revert Id87a90474, restoring the code that handles empty lines and
lines containing only a comment.

Change-Id: I7e014f29e9feeb271fd2fcc31be18704ceb4e02c