You can just use `line.isspace`.