<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_dftbp(filename, atoms):
 """Writes DFTB+ readable, gen-formatted structure files Args: filename: name of the gen-file to be written atoms: object containing information about structure """

    scale_pos = dftbpToBohr

    lines = ""

    # 1. line, use absolute positions
    natoms = atoms.get_number_of_atoms()
    lines += str(natoms)
    lines += ' S \n'

    # 2. line
    expaned_symbols = atoms.get_chemical_symbols()
    symbols = get_reduced_symbols(expaned_symbols)
    lines += ' '.join(symbols) + '\n'

    atom_numbers = []
    for ss in expaned_symbols:
        atom_numbers.append(symbols.index(ss) + 1)

    positions = atoms.get_positions()/scale_pos

    for ii in range(natoms):
        pos = positions[ii]
        pos_str = "{:3d} {:3d} {:20.15f} {:20.15f} {:20.15f}\n".format(
            ii + 1, atom_numbers[ii], pos[0], pos[1], pos[2])
        lines += pos_str

    # origin arbitrary
    lines +='0.0 0.0 0.0\n'

    cell = atoms.get_cell()/scale_pos

    for ii in range(3):
        cell_str = "{:20.15f} {:20.15f} {:20.15f}\n".format(
            cell[ii][0], cell[ii][1], cell[ii][2])
        lines += cell_str

    outfile = open(filename, 'w')
    outfile.write(lines)