Fixed bug with writing to arbitrary file location.