help on page break

Hi,

i have a file say samp.s which has

123 a b c d
123 e f g h
123 i j k l
123 m n o p
234 a b c d
234 e f g h
234 i j k l

the first 3 characters in each line are considered the key values

i have one more file temp.txt which has

123
234

i want to have a page break in the following manner

123 a b c d
123 e f g h
123 i j k l
(page break)
123 m n o p
(page break)
234 a b c d
234 e f g h
234 i j k l
(page break)

After 3 lines i need to have a page break.

can someone help me on this.

Thanks,
Sheema

if you have Python

#!/usr/bin/env python
temp=open("temp.txt").read().split("\n")
d={}
for line in open("file"):
    old=line
    line=old.split()
    if line[0] in temp:        
        d.setdefault(line[0],[])
        d[line[0]].append(old)        
for k in temp:
    if len(d[k]) %3 !=0:
        d[k].append("\n")
    for n,item in enumerate(d[k]):         
        if n%4==0:    
            d[k][n-1]=d[k][n-1].strip()        
            d[k].insert(n,"\n\n")
    d[k].pop(0)        
    print ''.join(d[k])

output

# more temp.txt
123 a b c d
123 e f g h
123 i j k l
123 m n o p
123 q r s t
123 u v w x
123 o o o o
234 a b c d
234 e f g h
234 i j k l
234 a b c d
234 e f g h
234 i j k l
234 w x y z

# ./test.py
123 a b c d
123 e f g h
123 i j k l

123 m n o p
123 q r s t
123 u v w x

123 o o o o

234 a b c d
234 e f g h
234 i j k l

234 a b c d
234 e f g h
234 i j k l

234 w x y z




ghostdog74,

I hope it's not the Output Sheema is expecting.

??? don't understand.
anyway, i assume the criteria to add newline is when the first column corresponds to what
temp.txt has.

According to Sheema's output , there should be a pagebreak after every three lines ( of course which should present in temp.txt) and if the first field is varied in the list of next three lines then page break should be done .

123 a b c d
123 e f g h
123 i j k l
(page break)
123 m n o p
(page break)
234 a b c d
234 e f g h
234 i j k l
(page break)

@ghostdog74 - Thanks for the input
@Panyam - That's exactly the requirement.