use read function instead of readline
add test_scan