Saving received data in a file