I changed to using line = line.strip() instead of line = line [:-1] in the original and it it worked. Thanks!