def write_pid(pid_file):

    try:
        pidfd = open(pid_file, 'w')
    except IOError, ex:
        log.error("Failed to open PID file %s" % pid_file)
        log.error("Error: %s" % (ex,))
        sys.exit(1)

    pidfd.write("%s\n" % os.getpid())
    pidfd.close()
Count the number of newlines in the given string and append them.
dataset/ETHPy150Open marineam/nagcat/python/nagcat/util.py/write_pid--crossover with--dataset/ETHPy150Open google/closure-linter/closure_linter/common/htmlutil.py/ScriptExtractor._AppendNewlines