GAMESS Input Preparation and subsequent file manipulations

Typical Cartesian file from Chem3D

It just contains number of atoms in the first line, followed by name of atoms and Cartesian coordinates.
 36
  C    0.392731   -0.000534   -3.984268
  N    1.298492    0.114838   -2.873383
  C    1.624832    1.506653   -2.718063
  C    0.595612   -0.304000   -1.690857
  C   -0.569778    0.597794   -1.261948
  N   -1.257706    0.165466   -0.017685
  C   -0.579330    0.502045    1.262650
  C    0.586853   -0.421860    1.631592
  N    1.125946   -0.032425    2.906357
  C    2.410767   -0.661926    3.048309
  C    0.263428   -0.564224    3.926575
  C   -2.054108   -1.015228   -0.032837
  O   -2.465408   -1.420456   -1.259796
  H   -3.068130   -2.149643   -1.155823
  O   -2.405533   -1.679611    0.933792
  H    0.507660   -0.086914    4.883057
  H    0.347382   -1.654663    4.047302
  H   -0.781250   -0.324875    3.668274
  H    2.861420   -0.342239    3.996384
  H    3.068115   -0.338882    2.230942
  H    2.363968   -1.761642    3.041718
  H    2.111053    1.856461   -3.637482
  H    2.331619    1.629898   -1.887466
  H    0.751587    2.149658   -2.526825
  H    0.151657   -1.057449   -4.154388
  H    0.888367    0.387756   -4.883072
  H   -0.550354    0.550949   -3.847000
  H    1.395096   -0.347488    0.867950
  H    0.260757   -1.484879    1.637421
  H    1.349030   -0.376343   -0.872406
  H    0.238922   -1.336639   -1.878998
  H   -1.342819    0.481567    2.075700
  H   -0.237700    1.553665    1.181244
  H   -1.332596    0.664124   -2.065033
  H   -0.216995    1.635284   -1.084839
  H    1.025925    1.022232    2.906311