Properly handle embedded null bytes with readline() and friends