Fixed typo that resulted in write to closed filehandle. Resolves #224.