public static function writeLines($path, $lines)
    {
        if (is_file($path) && !is_writable($path)) {
            throw new RuntimeException("File '$path' is not a writable file");
        }

        // make sure every line has only one newline at the end
        $lines = array_map(function ($line) {
            return rtrim($line);
        }, $lines);

        $bytes = file_put_contents($path, implode("\n", $lines));
        if ($bytes === false) {
            throw new RuntimeException("Something went wrong while writing content to '$path'");
        }

        return true;
    }