def grep(filename, tag, firstOccurrence=False):
    """Greps the line that starts with a specific `tag` string from inside a file."""
    import re

    try:
        afile = open(filename, "r")
    except:
        print("Error in utils.grep(): cannot open file", filename)
        exit()
    content = None
    for line in afile:
        if re.search(tag, line):
            content = line.split()
            if firstOccurrence:
                break
    if content:
        if len(content) == 2:
            content = content[1]
        else:
            content = content[1:]
    afile.close()
    return content
Greps the line that starts with a specific `tag` string from inside a file.