there's a try here, but no catch?
writer.close() should be in finally.