@Override
 protected String getInitialFileContent(final IFile newFileHandle, final SubMonitor m) {
   final String lineDelimiter = TextUtil.getLineDelimiter(newFileHandle.getProject());
   final IRSourceUnit su =
       (IRSourceUnit)
           LTK.getSourceUnitManager()
               .getSourceUnit(
                   LTK.PERSISTENCE_CONTEXT,
                   newFileHandle,
                   getContentType(newFileHandle),
                   true,
                   m);
   try {
     final EvaluatedTemplate data = CodeGeneration.getNewRFileContent(su, lineDelimiter);
     if (data != null) {
       fInitialSelection = data.getRegionToSelect();
       return data.getContent();
     }
   } catch (final CoreException e) {
     RUIPlugin.logError(
         ICommonStatusConstants.INTERNAL_TEMPLATE,
         "An error occured when applying template to new R script file.",
         e); //$NON-NLS-1$
   } finally {
     if (su != null) {
       su.disconnect(m);
     }
   }
   return null;
 }
 private int getNextLineOffset(final IDocument doc, final int endLine) {
   try {
     if (endLine >= 0 && endLine + 1 < doc.getNumberOfLines()) {
       return doc.getLineOffset(endLine + 1);
     } else {
       return -1;
     }
   } catch (final BadLocationException e) {
     // don't show an error
     RUIPlugin.logError(RUIPlugin.INTERNAL_ERROR, "Error while find next line.", e); // $NON-NLS-1$
     return -1;
   }
 }