Hi, Jesus, > Maybe you can read it completely in memory, reorganize the contents > per file, and then write each file at once. > I think that should speed it up, although it implies a complete > refactor of the code. Could you please give me some tips on how to organize this new script ? I have no idea to do this at all. >> Item 2, the original data has 21 lines header. Although it could be >> deleted then read by the script. But I do want to update the script >> to make it exclude the fist 21 lines header. > > If you do a first file.readline after opening the file, you will read > the first line. > Then continue with what you already had. As to this problem, I solved by insert this code. until file.readline =~ /Data:/ file.readline end Thanks a lot in advance ! Cheers, Junhui -- Posted via http://www.ruby-forum.com/.