---
title: "Check if a StreamReader can read another line"  
description: "Check if a StreamReader can read another line"  
author: "Anonymous User"  
published: 2014-01-31  
updated: 2014-01-31  
canonical: https://www.mindstick.com/forum/1934/check-if-a-streamreader-can-read-another-line  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Check if a StreamReader can read another line

I need to [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) a line contains a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) before I read it, I want to do this using a [while loop](https://www.mindstick.com/forum/34579/while-loop-in-python) something like this

while(reader.ReadLine() != [null](https://www.mindstick.com/forum/33922/how-to-use-null-coalescing-operator-in-c-sharp))

{

[array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net)[i] = reader.ReadLine();

}

This obviously doesen't work, so how can I do this [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box)?

## Replies

### Reply by Pravesh Singh

Hi Tanuj,\
Try this:\

String row;

while((row=reader.ReadLine())!=null){

array[i]=row;

}

\


---

Original Source: https://www.mindstick.com/forum/1934/check-if-a-streamreader-can-read-another-line

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
