Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    ans = n + 1
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                ans += 1
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                if (x, y, det) in m:
                    m[(x, y, det)] += 1
                else:
                    m[(x, y, det)] = 1
    for p in m:
        S = 0
        cnt = 0
        while True:
            S += cnt
            if m[p] == S:
                ans -= cnt * (cnt - 1) // 2
                break
            cnt += 1
    print(ans)


Fixed submission:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    ans = n + 1
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                ans += 1
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                if (x, y, det) in m:
                    m[(x, y, det)] += 1
                else:
                    m[(x, y, det)] = 1
    for p in m:
        S = 0
        cnt = 0
        while True:
            S += cnt
            if m[p] == S:
                ans -= cnt * (cnt - 1) // 2
                break
            cnt += 1
    print(ans)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                ans += 1
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                m[(x, y, det)] = 1
    print(1 + n + len(m))


Fixed submission:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    ans = n + 1
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                ans += 1
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                if (x, y, det) in m:
                    m[(x, y, det)] += 1
                else:
                    m[(x, y, det)] = 1
    for p in m:
        S = 0
        cnt = 0
        while True:
            S += cnt
            if m[p] == S:
                ans -= cnt * (cnt - 1) // 2
                break
            cnt += 1
    print(ans)