read and write in serial file