<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def emit_arg(keywordstr, stmt, fd, indent, indentstep, max_line_len, line_len):
 """Heuristically pretty print the argument string with double quotes"""

    arg = escape_str(stmt.arg)
    lines = arg.splitlines(True)
    if len(lines) <= 1:
        if len(arg) > 0 and arg[-1] == '\n':
            arg = arg[:-1] + r'\n'
        if (stmt.keyword in _force_newline_arg or
            need_new_line(max_line_len, line_len, arg)):
            fd.write('\n' + indent + indentstep + '"' + arg + '"')
            return True
        else:
            fd.write(' "' + arg + '"')
            return False
    else:
        need_nl = False
        if stmt.keyword in _force_newline_arg:
            need_nl = True
        elif len(keywordstr) > 8:
            # Heuristics: multi-line after a "long" keyword looks better
            # than after a "short" keyword (compare 'when' and 'error-message')
            need_nl = True
        else:
            for line in lines:
                if need_new_line(max_line_len, line_len + 1, line):
                    need_nl = True
                    break
        if need_nl:
            fd.write('\n' + indent + indentstep)
            prefix = indent + indentstep
        else:
            fd.write(' ')
            prefix = indent + len(keywordstr) * ' ' + ' '
        fd.write('"' + lines[0])
        for line in lines[1:-1]:
            if line[0] == '\n':
                fd.write('\n')
            else:
                fd.write(prefix + ' ' + line)
        # write last line
        fd.write(prefix + ' ' + lines[-1])
        if lines[-1][-1] == '\n':
            # last line ends with a newline, indent the ending quote
            fd.write(prefix + '"')
        else:
            fd.write('"')
        return True