What you mean is to transpose the file, an operation which has beencoveredbefore.
For future reference, if your question has probably already been answered, please use the sites search functionality. It's conveniently located at the top right of every page, and gives good results for 'transpose file contents'