fixed bug when stdin is empty