Extract file statements only for toplevel blocks

This prevents a bug where empty method bodies were emitted when the
--extract-file option was used.