That's because you are trying to run strip on the tag class within beautiful soup.
Change line 14 to:
line = line.string.strip()
However be aware that this can still be None when the tag you are searching for has multiple sub elements. Seee link to string method on doco for beautiful soup