added  support for reading from stdin