read and write working for single-threaded, one liner