fixed bug in view.sample (output variable should have been 'stdout')