Writes a shebang to the first line of the file according to the specified
    version. (2 | 3 | default)
504621
def put_shebang(f, version):
    
    if not contains_shebang(f):
        f.seek(0)
        original_text = f.read()
        f.seek(0)
        f.write(shebangs[version] + original_text)
1289468
def writeline(self, line, line_number):
        
        tmp_file = tempfile.TemporaryFile('w+')
        if not line.endswith(os.linesep):

            line += os.linesep
        try:

            with open(self.path, 'r') as file_handle:

                for count, new_line in enumerate(file_handle):

                    if count == line_number:

                        new_line = line

                    tmp_file.write(new_line)

            tmp_file.seek(0)
            with open(self.path, 'w') as file_handle:

                for new_line in tmp_file:

                    file_handle.write(new_line)
        finally:

            tmp_file.close()
1079662
function saveNewVersion(version, versionFile) {
    fs.writeFileSync(versionFile, JSON.stringify({
        version
    }, null, 2), 'UTF-8');
}
1244210
function writefile(filepath, filetext, options) {
		var version = '-1.0.0';
		var packag = filename('package.json', options);
		var banner = filename('BANNER.txt', options);
		if (grunt.file.exists(banner)) {
			filetext = grunt.file.read(banner) + '\n' + filetext;
		}
		if (grunt.file.exists(packag)) {
			var json = grunt.file.readJSON(packag);
			version = json.version;
		}
		grunt.file.write(
			filepath,
			grunt.template.process(filetext, {
				data: {
					version: version
				}
			})
		);
		grunt.log.writeln('File "' + chalk.cyan(filepath) + '" created.');
	}
54999
function firstFourLines(file, options) {
  file.excerpt = file.content.split('\n').slice(0, 4).join(' ');
}
1216366
def first_up(ofile, Rec, file_type):
    
    keylist = []
    pmag_out = open(ofile, 'a')
    outstring = "tab \t" + file_type + "\n"
    pmag_out.write(outstring)
    keystring = ""
    for key in list(Rec.keys()):
        keystring = keystring + '\t' + key
        keylist.append(key)
    keystring = keystring + '\n'
    pmag_out.write(keystring[1:])
    pmag_out.close()
    return keylist
1001030
def make_exec(fname, version):
    
    # if no version is specified, use system default.
    if version is None:
        version = 'default'

    # write the shebang and then make the file executable.
    with open(fname, 'rb+') as f:
        put_shebang(f, version)
    # make the file
    os.chmod(fname, os.stat(fname).st_mode | 0o0111)
    print("{} is now executable".format(fname))
404687
def shebang(self):
        """"""
        with open(self.path, 'rb') as file_handle:
            hashtag = file_handle.read(2)
            if hashtag == b'#!':

                file_handle.seek(0)
                return file_handle.readline().decode('utf8')

        return None
35647
def get_shebang(tokens):
    
    # This (short) loop preserves shebangs and encoding strings:
    for tok in tokens[0:4]: # Will always be in the first four tokens
        line = tok[4]
        # Save the first comment line if it starts with a shebang
        # (e.g. '#!/usr/bin/env python')
        if shebang.match(line): # Must be first line
            return line
588369
def simple_write(filename, group, times, features,
                 properties=None, item='item', mode='a'):
    """"""
    write(filename, group, [item], [times], [features], mode=mode,
          properties=[properties] if properties is not None else None)
168820
def writeto(self, filename, **kwargs):
        
        fits.PrimaryHDU(header=self).writeto(filename, output_verify='ignore', **kwargs)
986098
def add_line_numbers(src)
      if src =~ /\A.*, line (\d+)/
        first = $1.to_i - 1
        last  = first + src.count("\n")
        size = last.to_s.length
        fmt = "%#{size}d: "
        is_first_line = true
        line_num = first
        src.gsub!(/^/) do
          if is_first_line then
            is_first_line = false
            res = " " * (size+2)
          else
            res = sprintf(fmt, line_num)
          end

          line_num += 1
          res
        end
      end
    end
542950
def add_line_numbers(src)
            if src =~ /\A.*, line (\d+)/
                first = $1.to_i - 1
                last  = first + src.count("\n")
                size = last.to_s.length
                real_fmt = "%#{size}d: "
                fmt = " " * (size+2)
                src.gsub!(/^/) do
                    res = sprintf(fmt, first) 
                    first += 1
                    fmt = real_fmt
                    res
                end
            end
        end
502053
def write_line(self, line=None, *args, **kwargs):
        
        if line is None:
            # Empty line
            self.write("\n")
        else:
            # Format the line, if arguments have been given
            if args or kwargs:
                line = line.format(*args, **kwargs)

            with self.__lock:
                # Write it
                self.write(line)
                try:
                    if line[-1] != "\n":
                        # Add the trailing new line
                        self.write("\n")
                except IndexError:
                    # Got an empty string
                    self.write("\n")

        self.flush()
1273308
def getfirstline(file, default):
    
    with open(file, 'rb') as fh:
        content = fh.readlines()
        if len(content) == 1:
            return content[0].decode('utf-8').strip('\n')

    return default
986451
def set_version(new_version_number=None, old_version_number=''):
    
    if new_version_number is None:
        return ValueError

    import fileinput
    import sys

    file = join('timezonefinder', '__init__.py')

    for line in fileinput.input(file, inplace=1):
        if old_version_number in line:
            line = line.replace(old_version_number, new_version_number)
        sys.stdout.write(line)
737953
public void writeTreesInOneLineFormat(File outFile) throws IOException {
        BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
        for (BinaryTree tree : this) {
            writer.write(tree.getAsOneLineString());
            writer.write("\n");
        }
        writer.close();        
    }