# POTD 16 skel
# Author:
# Date:
# Description:

def encode_rle(input_file, rle_file):
    """ Read the given input file and write a run-length encoding of its
    contents to output_file. Each input line is run-length encoded
    independently and separated by newlines in the output.
    Returns the compression ratio - that is, the ratio of the output file's
    length to the input file's length. When counting file length, ignore
    newline characters.
    Precondition: input_file exists."""

    f = open(input_file, 'r')
    for line in file:
        # call encode_line on line.rstrip("\n") and write to output file
        
    f.close()
    

def decode_rle(rle_file, output_file):
    """ Decode the run-length encoded rle_file and write its decoded contents
    to output_file. Precondition: rle_file exists and is encoded according to
    the spec for encode_rle. """
    
    # implement this function


# Suggested helper functions 
# You may find it helpful to implement the functions below and use them in the
# above functions, but these are not directly tested by the test program.

def encode_line(line):
    """ Run-length encode a single line of text. """
    result = ""
    char = contents[0]
    count = 0
    for c in contents:
        if c == char:
            count += 1
        else:
            # output the prior run count and char
            result += str(count) + char
            
            # reset to start a new run
            char = c
            count = 1
            
    result += str(count) + char
        # or add the character to an existing run
        
    
#     while #i still have string:
#         while # i'm in the same run
#             read a character

def decode_line(line):
    """ Run-length decode a single line of text. """

