replace read() with g_io_channel_read_chars()