+bool wxTextFile::OnRead(wxMBConv& conv)
+{
+    // file should be opened and we must be in it's beginning
+    wxASSERT( m_file.IsOpened() && m_file.Tell() == 0 );
+
+    char *strBuf, *strPtr, *strEnd;
+    char ch, chLast = '\0';
+    char buf[1024];
+    size_t nRead;
+
+    strPtr = strBuf = new char[1024];
+    strEnd = strBuf + 1024;
+
+    do
+    {
+        nRead = m_file.Read(buf, WXSIZEOF(buf));
+        if ( nRead == (size_t)wxInvalidOffset )
+        {
+            // read error (error message already given in wxFile::Read)
+            delete[] strBuf;
+            return false;
+        }
+
+        for (size_t n = 0; n < nRead; n++)
+        {
+            ch = buf[n];
+            switch ( ch )
+            {
+                case '\n':
+                    // Dos/Unix line termination
+                    *strPtr = '\0';
+                    AddLine(wxString(strBuf, conv),
+                            chLast == '\r' ? wxTextFileType_Dos
+                                           : wxTextFileType_Unix);
+                    strPtr = strBuf;
+                    chLast = '\n';
+                    break;
+
+                case '\r':
+                    if ( chLast == '\r' )
+                    {
+                        // Mac empty line
+                        AddLine(wxEmptyString, wxTextFileType_Mac);
+                    }
+                    else
+                        chLast = '\r';
+                    break;
+
+                default:
+                    if ( chLast == '\r' )
+                    {
+                        // Mac line termination
+                        *strPtr = '\0';
+                        AddLine(wxString(strBuf, conv), wxTextFileType_Mac);
+                        chLast = ch;
+                        strPtr = strBuf;
+                        *(strPtr++) = ch;
+                    }
+                    else
+                    {
+                        // add to the current line
+                        *(strPtr++) = ch;
+                        if ( strPtr == strEnd )
+                        {
+                            // we must allocate more memory
+                            size_t size = strEnd - strBuf;
+                            char *newBuf = new char[size + 1024];
+                            memcpy(newBuf, strBuf, size);
+                            delete[] strBuf;
+                            strBuf = newBuf;
+                            strEnd = strBuf + size + 1024;
+                            strPtr = strBuf + size;
+                        }
+                    }
+            }
+        }
+    } while ( nRead == WXSIZEOF(buf) );
+
+    // anything in the last line?
+    if ( strPtr != strBuf )
+    {
+        *strPtr = '\0';
+        AddLine(wxString(strBuf, conv),
+                wxTextFileType_None); // no line terminator
+    }