Automatically detect PHP_VERSION and workaround stream_get_line bug