#!/usr/bin/env python3

#NOTE: this is here because of possible BioLegato interactions!

import sys

"""
# Write out the contents of a file, starting at line $1
# This command replaces 'tail +number', which is no longer
# supported in Linux

Synopsis: btail.py  STARTLINE  INFILE  OUTFILE
"""

""" ensure that there are enough command line arguments to parse """
if len(sys.argv) < 4:
    print("Missing parameter");
    print("");
    print("Usage: btail.py  STARTLINE  INFILE  OUTFILE");
    exit();

""" get the URL to open (the first command line argument) """
startline = int(sys.argv[1])
infile = open(sys.argv[2], 'r')
outfile = open(sys.argv[3], 'w')
count = 1;

for line in infile:
    if count >= startline:
        outfile.write(line)
    count = count + 1

infile.close()
outfile.close()
