#! /usr/bin/python

# Print out first n*size lines in input file

import sys
import math
import os.path 
import gzip

def main():
    n = float(sys.argv[1])
    infile = sys.argv[2]
    if os.path.splitext(infile) == ".gz":
        inp = gzip.GzipFile(infile)
    else:
        inp = open(infile)
    lines = [ ln for ln in inp ]
    size = math.trunc(n * len(lines))
    for ln in lines[0:size]:
        sys.stdout.write(ln)

if __name__ == '__main__':
    main()
