#!/usr/bin/python

# pair_text_lines.py
#       --copyright--                   Copyright 2007 (C) Tranzoa, Co. All rights reserved.    Warranty: You're free and on your own here. This code is not necessarily up-to-date or of public quality.
#       --url--                         http://www.tranzoa.net/tzpython/
#       --email--                       pycode is the name to send to. tranzoa.com is the place to send to.
#       --bodstamps--
#       February 12, 2005       bar
#       February 14, 2005       bar     write the output file
#       November 18, 2007       bar     turn on doxygen
#       November 27, 2007       bar     insert boilerplate copyright
#       May 17, 2008            bar     email adr
#       May 27, 2012            bar     doxygen namespace
#       --eodstamps--
##      \file
#       \namespace              tzpython.pair_text_lines
#
#
#       Print out all pairs of text lines on separate text lines.
#
#       E.g. File has:
#
#           abc
#           def
#           ghi
#
#       Output is:
#
#           abc def
#           abc ghi
#           def ghi
#
#

if  __name__ == '__main__' :
    import  sys

    fi     = sys.stdin
    if  len(sys.argv) >= 2 :
        fi = open(sys.argv[1], "r")

    lines = []

    while True :
        li = fi.readline()
        if  not li :    break

        li = li.strip()

        if  len(li) != 0 :
            lines.append(li)
        pass

    if  fi != sys.stdin :
        fi.close()


    fo     = sys.stdout
    if  len(sys.argv) >= 3 :
        fo = open(sys.argv[2], "w")

    for i in range(0, len(lines) - 1) :
        for j in range(i + 1, len(lines)) :
            print >> fo, lines[i], lines[j]
        pass

    if  fo != sys.stdout :
        fo.close()

    pass

#
#
#
# eof
