---
title: "vbscript skipline and cr line endings"  
description: "vbscript skipline and cr line endings"  
author: "Anonymous User"  
published: 2013-06-20  
updated: 2013-06-20  
canonical: https://www.mindstick.com/forum/1223/vbscript-skipline-and-cr-line-endings  
category: "vb script"  
tags: ["vb script"]  
reading_time: 2 minutes  

---

# vbscript skipline and cr line endings

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances),\
\
For some reason when I use the objFile.ReadLine [method](https://www.mindstick.com/forum/166/webservice-method) to read my [text file](https://www.mindstick.com/forum/12828/converting-a-text-file-to-an-array-in-java), the entire file is returned [as one](https://answers.mindstick.com/qa/34642/which-indian-it-company-has-been-recognized-as-one-of-the-world-s-best-employers-by-the-top-employer-institute-for-the-third-consecutive-year) [long](https://www.mindstick.com/articles/44565/white-wedding-dresses-long-prom-dresses) line. The file I'm opening is using CR line endings instead of CRLF or LF line endings. Does [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) know how I can read this file [line by line](https://www.mindstick.com/interview/34101/how-do-you-read-a-file-line-by-line-using-a-generator-like-approach-e-g-yield-return) in vbscript if ReadLine does not recognize CR line endings? [Code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) is below:\
\

```
Set objFSO = CreateObject("Scripting.FileSystemObject")Set txsInput = objFSO.OpenTextFile("C:\Path\To\My\File.csv",1)'Read lines one by one Do While txsInput.AtEndOfStream <> True  strTemp = txsInput.ReadLine  msgbox strTempLoop
```

\
Instead of alerting for each line, I get one [alert](https://answers.mindstick.com/qa/30927/what-is-an-alert) with the entire file. Any help is appreciated.\

## Replies

### Reply by Vijay Shukla

Hi Pravesh,\
.ReadLine won't work in your case, because it depends on the existence of a vbLf character. If you don't want to re-encode the line breaks or read the entire [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) and split it at vbCr (if the file is not-so-large):\
**text = objFSO.OpenTextFile("C:\Path\To\My\File.csv").ReadAll**\
For Each line In Split(text, vbCr)MsgBox lineNextRe-encoding the file can be done like this:\
Set fso = CreateObject("Scripting.FileSystemObject")filename = "C:\path\to\your.csv"Set infile = fso.OpenTextFile(filename)Set outfile = fso.OpenTextFile(filename & ".tmp", 2)\
Do Until infile.AtEndOfStreamc = infile.Read(1)If c = vbCr Thenoutfile.Write vbCrLfElseoutfile.Write cEnd IfLoop\
infile.Closeoutfile.Close\
fso.DeleteFile filename, Truefso.MoveFile filename & ".tmp", filename\
Or you could use something like recode for the conversion. Most text editors (e.g. Vim, Notepad++, SciTE, UltraEdit, …) can do this kind of conversion, too.\
\


---

Original Source: https://www.mindstick.com/forum/1223/vbscript-skipline-and-cr-line-endings

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
