I had already tried what you said to output to the file but it was not working. I was previously trying this without opening the file in the beginning of the code which solved my problem. As for the problem when the data skips to a new line, I actually solved that by myself. I saw your code but decided I should at least attempt before getting help. Thank you for all the help!