# Puts - not putting 'all' content on display console

**URL:** <https://www.ruby-forum.com/t/puts-not-putting-all-content-on-display-console/186228>\
**Category:** Ruby\
**Created:** [April 2, 2010, 3:43pm UTC](https://www.ruby-forum.com/t/puts-not-putting-all-content-on-display-console/186228 "2010-04-02T15:43:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@daz](https://www.ruby-forum.com/u/daz)\
**Post date:** [April 2, 2010, 3:43pm UTC](https://www.ruby-forum.com/t/puts-not-putting-all-content-on-display-console/186228/1 "2010-04-02T15:43:33Z")

</div>

I am using Ruby 1.86 to process a 7,000+ record file and using Regular  
Expressions to select and process content. To ensure that the Regexp  
are working correctly, I have been using â€œputsâ€ to direct selected  
records to the console for examination. On examining the console output  
from the â€œputsâ€ command I donâ€™t seem to get all of the records being  
selected through the Regexp. My question is this: in using a simple  
â€˜putsâ€™ command, is there some argument that must be added to get every  
selected record to be displayed on the console output? And since I can  
associate each record in the 7,000+ file with a record count number, is  
there any reason to believe that the output to the console would not  
appear in the same sequence as the record numbers being encountered?

---

<div class="post-metadata">

**Author:** ![daz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@daz](https://www.ruby-forum.com/u/daz)\
**Post date:** [April 2, 2010, 5:39pm UTC](https://www.ruby-forum.com/t/puts-not-putting-all-content-on-display-console/186228/2 "2010-04-02T17:39:43Z")

</div>

On Fri, Apr 2, 2010 at 7:43 AM, Dave B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> appear in the same sequence as the record numbers being encountered?  
> Umm… there is not.  
> Can you post some code here? Do you have the same problem when working  
> with a smaller version of the record file?

-drd

---

<div class="post-metadata">

**Author:** ![daz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@daz](https://www.ruby-forum.com/u/daz)\
**Post date:** [April 2, 2010, 9:42pm UTC](https://www.ruby-forum.com/t/puts-not-putting-all-content-on-display-console/186228/3 "2010-04-02T21:42:39Z")

</div>

On Fri, Apr 2, 2010 at 8:43 AM, Dave B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> appear in the same sequence as the record numbers being encountered?  
> puts is buffered. Try calling $stdout.flush.

---

<div class="post-metadata">

**Author:** ![daz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@daz](https://www.ruby-forum.com/u/daz)\
**Post date:** [April 3, 2010, 7:00pm UTC](https://www.ruby-forum.com/t/puts-not-putting-all-content-on-display-console/186228/4 "2010-04-03T19:00:04Z")

</div>

David Rio wrote:

> On Fri, Apr 2, 2010 at 7:43 AM, Dave B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > appear in the same sequence as the record numbers being encountered?  
> > Umm… there is not.  
> > Can you post some code here? Do you have the same problem when working  
> > with a smaller version of the record file?
> 
> -drd

I have redirected the output to a file instead of just using the  
console. I am getting all of the records so it would seem that the  
program is OK. But experimenting further with the previous console  
output using puts, whenI remove the Regexp filtering component, I can  
see all 7,000 records flying by. As the other responder said, it must  
be the way that things get buffered. Why when I add the Regexp process  
the console output seems to get constrained is still a mystery. Thank  
you for your response.

db
