BOOL CFileBasedProjectTemplateItem::CreateMainFile(LPCTSTR lpszTargetPath, LPCTSTR lpszCrLf)
{
	CStringW text;
	TextDocument doc;

	bool result = doc.Read(m_strPath,text);

	if (result)
	{
		const CStringW lineendings(L"\r\n");
		int index = text.FindOneOf(lineendings);

		if (index != -1)
		{
			CStringW line = text.Left(index);
			const CStringW strKey(L"%DESCRIPTION: ");
			CStringW strStartOfLine = line.Left(strKey.GetLength());

			strStartOfLine.MakeUpper();

			if (strKey == strStartOfLine) 
			{
				text.Delete(0,index);
				text.TrimLeft(lineendings + L' ');
			}
		}

		LPCWSTR le = GetLineEnding(static_cast<LPCWSTR>(text),text.GetLength());

		USES_CONVERSION;

		if (std::wcscmp(le,T2CW(lpszCrLf)) != 0) // Line endings not equal
			text.Replace(le,lpszCrLf);

		result = doc.Write(lpszTargetPath,text);
	}

	return result;
}