def break_top_line(string, line_length):
    """
    Takes a string containing a scramble and returns a string that is the same
    as the first string but with a newline in there that doesn't break any
    moves but also makes the length of the new first line less than the `line_length`
    """
    moves = string.split(' ')
    substrings = [' ' for _ in range(len(moves) - 1)]  # moves or spaces
    for i, move in enumerate(moves):
        substrings.insert(i * 2, move)
    lengths = [len(substring) for substring in substrings]
    
    newline_index = 0

    previous_sum = 0
    for i in range(len(lengths)):
        slice_sum = sum(lengths[:i])
        if line_length == slice_sum:
            newline_index = slice_sum
            break
        if (line_length < slice_sum) and (line_length > previous_sum):
            newline_index = previous_sum
            break
        previous_sum = slice_sum
    
    chars = list(string)
    chars.insert(newline_index, '\n')
    return ''.join(chars)