mime[:mime.find(";")] will remove last character if mime does not contain ";". Use mime.split(";") instead.