CR - carriage return
LF - line feed
In "cpp.properties", any new line is set as CRLF, but when the text document has been written to "bbb.txt", CRCRLF appears in "bbb.txt" instead of CRLF. Can anyone please tell me where the problem lies in?


Code:
#include <iostream>
#include <fstream>
#include <windows.h>

typedef unsigned short int usint;

int main(usint arg, char *parameter[]) {
	if (arg == 2) {
		using namespace std;
		ifstream::pos_type size;
		char *memblock;
		const char *convert;
		string search = "command.build.*.cpp=M:/Dev-Cpp/bin/g++.exe -o \"$(FileName)\" \"$(FileName).$(FileExt)\"";
		string link_file = " -Xlinker ";
		link_file += parameter[1];
		string filebuffer;
		
		ifstream readfile ("M:/SciTE/cpp.properties", ios::in|ios::binary|ios::ate);
		if (readfile.is_open()) {
			size = readfile.tellg();
			memblock = new char [size];
			readfile.seekg (0, ios::beg);
			readfile.read (memblock, size);
			readfile.close();
			filebuffer = memblock;
			delete []memblock;
			
			filebuffer.insert((filebuffer.find(search, 0) + 93), link_file);
			ofstream writefile("M:/bbb.txt");
			if (writefile.is_open()) {
				writefile << filebuffer;
				writefile.close();
				system("M:/bbb.txt");
			}
			else {
				MessageBox (NULL, "Unable to WRITE file.", "ERROR", MB_OK);
				goto end;
			}
			
		}
		else {
			MessageBox (NULL, "Unable to READ file.", "ERROR", MB_OK);
			goto end;
		}
		
		
		end: return 0;
	}
}