fix reading from pipes