Added null check before checking the length of the line.