File saving

Now the file is open at the beginning of the cycle and one row at time
is added. This removes the need to create a separate array to store
temperatures and humidity. Also data is not lost if something happen.