import codecs
import re


def get_replies(message_file, charset=None):
    """ Finds replies within a message and returns a list containing each reply.
    
    Args:
        message_file (str): The email's filename.
        charset (str): The optional codec to use for opening the file.
    
    Returns:
        list: Each item is a reply consisting of a list of lines.
    """

    # place breakpoints for each reply in list. 
    breakpoints = [0]

    # parse message.
    with codecs.open(message_file, "r", encoding=charset) as message:
        message = message.read()
        message = re.sub(r".[-]+[\s]{0,}Original Message[\s]{0,}[-]+\n", "", message,
                  flags=re.I) # remove original message headers.

        lines = message.split("\n")
        
        # get breakpoints for each reply. 
        i = 0
        for line in lines:
            if line[:6] == "From: ":
                breakpoints.append(i)
            i += 1
        
        # split message into list of replies.
        breakpoints.append(len(lines))
        breakpoint_range = range(0, len(breakpoints) -1)
        breakpoint_pairs = [(breakpoints[br], breakpoints[br+1]) for br in breakpoint_range]
        replies = [lines[bp[0]:bp[1]] for bp in breakpoint_pairs]
        return replies