diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog for Shellify
 
+## 0.13.0
+- Return exit code zero when some invalid options are passed
+- End shell and flake files with a newline character
+
 ## 0.12.0
 - Add --allow-local-pinned-registries-to-be-prioritized switch
 - Prioiritise registries favouring those not pinned to local
diff --git a/shellify.cabal b/shellify.cabal
--- a/shellify.cabal
+++ b/shellify.cabal
@@ -1,6 +1,6 @@
 cabal-version:      3.0
 name:               shellify
-version:            0.12.0.1
+version:            0.13.0.0
 
 author: Daniel Rolls
 maintainer: daniel.rolls.27@googlemail.com
diff --git a/src/Constants.hs b/src/Constants.hs
--- a/src/Constants.hs
+++ b/src/Constants.hs
@@ -4,11 +4,11 @@
 import Text.RawString.QQ (r)
 
 helpText :: Text -> Text
-helpText progName = "USAGE: " <> progName <> [r| -p [PACKAGES] 
-       |] <> progName <> [r| [--with-flakes] [PACKAGES]
+helpText progName = "USAGE: " <> progName <> [r| -p [PACKAGES] [--with-flakes]
+       |] <> progName <> [r| shell [PACKAGES]
 
 Pass nix-shell arguments to nix-shellify to have it generate a shell.nix in
-the current directory. You can then just run nix shell or nix-shell in that
+the current directory. You can then just run nix develop or nix-shell in that
 directory to have those packages in your environment. To run nix commands
 you must first install Nix.
 
@@ -21,8 +21,8 @@
     Command to run after creating the shell
 
     --with-flake
-    When using the command in a flake-like style use this switch to have a
-    flake.nix created in addition to a shell.nix. Highly recommended to ensure
+    When using the -p option to specify packages, use this switch to have a
+    flake.nix created in addition to a shell.nix. This is recommended to ensure
     the versions of dependencies are kept for reproducibility and so that
     shells are cached to load faster.
 
diff --git a/src/FlakeTemplate.hs b/src/FlakeTemplate.hs
--- a/src/FlakeTemplate.hs
+++ b/src/FlakeTemplate.hs
@@ -24,4 +24,6 @@
           devShells.default = import ./shell.nix { $shell_args;separator=' '$ };
         }
       );
-}|]
+}
+
+|]
diff --git a/src/Options.hs b/src/Options.hs
--- a/src/Options.hs
+++ b/src/Options.hs
@@ -1,4 +1,4 @@
-module Options (Package(..), Options(..), def, Packages, options) where
+module Options (Package(..), Options(..), OutputForm(..), def, Packages(Packages), options) where
 import Prelude hiding (takeWhile, writeFile)
 
 import Constants
@@ -23,14 +23,27 @@
 import System.IO (stderr)
 import Text.StringTemplate (newSTMP, render, setAttribute, StringTemplate)
 
+data OutputForm = Traditional
+                | Flake
+     deriving (Eq, Show)
+
+newtype Packages = Packages [ Package ] deriving Show
+
+
 type Package = Text
-type Packages = [ Package ]
+
+instance Eq Packages where
+  Packages a == Packages b = sort a == sort b
+
+packageList = toPackageList . packages
+  where toPackageList (Packages p) = p
+
 data Options = Options {
     packages :: Packages
   , command :: Maybe Text
-  , generateFlake :: Bool
+  , outputForm :: !OutputForm
   , prioritiseLocalPinnedSystem :: Bool
-}
+} deriving (Eq, Show)
 
 data OptionsParser = OptionsParser [Text] -- remainingOptions
                                    (Either Text (Options -> Options)) -- result
@@ -47,7 +60,7 @@
                let (OptionsParser newRemaining newRes) = f hd tl
                in worker $ OptionsParser newRemaining ((.) <$> newRes <*> res)
 
-      screenForNoPackages (Right opts) | null (packages opts) = Left noPackagesError
+      screenForNoPackages (Right opts) | null (packageList opts) = Left noPackagesError
       screenForNoPackages anyThingElse = anyThingElse
       initialArgumentsToParse = shellArgFilter args
       initialModifier = Right $ if hasShellArg args then setFlakeGeneration else id
@@ -66,7 +79,7 @@
         baseOption :: Text -> [Text] -> OptionsParser
         baseOption "-h" = returnError $ helpText progName
         baseOption "--help" = returnError $ helpText progName
-        baseOption "--version" = returnError $ "Shellify " <> (pack $ showVersion version)
+        baseOption "--version" = returnError $ "Shellify " <> pack ( showVersion version)
         baseOption "--command" = handleCommandSwitch
         baseOption "--run" = handleCommandSwitch
         baseOption "--with-flake" = transformOptionsWith setFlakeGeneration
@@ -81,13 +94,15 @@
                                     = transformOptionsWith (setCommand hd) tl
         handleCommandSwitch [] = returnError "Argument missing to switch" []
 
-        appendPackages ps opts = opts{packages=ps ++ packages opts}
+        appendPackages ps opts = opts{
+          packages = Packages (ps ++ packageList opts)
+        }
         setCommand cmd opts = opts{command=Just cmd}
-        setFlakeGeneration opts = opts{generateFlake=True}
+        setFlakeGeneration opts = opts{outputForm=Flake}
         setPrioritiseLocalPinnedSystem opts = opts {prioritiseLocalPinnedSystem=True}
         returnError errorText remaining = OptionsParser remaining $ Left errorText
 
-consumePackageArgs :: [Text] -> (Packages, [Text])
+consumePackageArgs :: [Text] -> ([Package], [Text])
 consumePackageArgs = worker []
   where worker pkgs [] = (pkgs, [])
         worker pkgs options@(hd:_) | isSwitch hd
@@ -102,10 +117,4 @@
 isSwitch = isPrefixOf "-"
 
 instance Default Options where
-  def = Options [] Nothing False False
-
-instance Eq Options where
-  a == b =  isEqual command
-         && isEqual (sort . packages)
-         && isEqual generateFlake
-    where isEqual f = f a == f b
+  def = Options (Packages []) Nothing Traditional False
diff --git a/src/Shellify.hs b/src/Shellify.hs
--- a/src/Shellify.hs
+++ b/src/Shellify.hs
@@ -25,8 +25,8 @@
 runShellify :: [Text] -> IO ()
 runShellify(pName:args) = getRegistryDB
              >>= either
-                   ((printErrorAndReturnFailure . ("Error calling nix registry: " <>) ) >=> exitWith)
-                   (\registryDB -> either printError
+                   (printErrorAndReturnFailure . ("Error calling nix registry: " <>))
+                   (\registryDB -> either printErrorAndReturnFailure
                                           (mapM_ createAFile)
                                           $ parseOptionsAndCalculateExpectedFiles registryDB pName args)
 
@@ -66,6 +66,6 @@
 shouldGenerateNewFile :: Maybe Text -> Bool
 shouldGenerateNewFile = (== Nothing)
 
-printErrorAndReturnFailure err = printError err >> return (ExitFailure 1)
+printErrorAndReturnFailure err = printError err >> exitWith (ExitFailure 1)
 printError = hPutStrLn stderr
 
diff --git a/src/ShellifyTemplate.hs b/src/ShellifyTemplate.hs
--- a/src/ShellifyTemplate.hs
+++ b/src/ShellifyTemplate.hs
@@ -17,4 +17,5 @@
   '';
 $endif$
 }
+
 |]
diff --git a/src/TemplateGeneration.hs b/src/TemplateGeneration.hs
--- a/src/TemplateGeneration.hs
+++ b/src/TemplateGeneration.hs
@@ -17,7 +17,7 @@
 import Text.StringTemplate (newSTMP, render, setAttribute)
 
 generateFlakeText :: Text -> Options -> Maybe Text
-generateFlakeText db Options{packages=packages, generateFlake=shouldGenerateFlake, prioritiseLocalPinnedSystem=prioritiseLocalPinnedSystem} =
+generateFlakeText db Options{packages=Packages packages, outputForm=outputForm, prioritiseLocalPinnedSystem=prioritiseLocalPinnedSystem} =
   bool
     Nothing
     (Just $ render
@@ -26,7 +26,7 @@
           $ setAttribute "pkgs_decls" pkgsDecls
           $ setAttribute "shell_args" shellArgs
           $ newSTMP flakeTemplate)
-    shouldGenerateFlake
+    (outputForm == Flake)
   where repos = getPackageRepoWrapper packages
         repoVars = getPackageRepoVarName <$> repos
         repoInputs = repoInput <$> repos
@@ -42,7 +42,7 @@
         shellArgs = (\(a,b) -> a <> "=" <> b <> ";") <$> zip repoVars pkgsVars 
 
 generateShellDotNixText :: Options -> Text
-generateShellDotNixText Options{packages=packages, command=command} =
+generateShellDotNixText Options{packages=Packages packages, command=command} =
   render
   $ setAttribute "build_inputs" pkgs
   $ setAttribute "parameters" parameters
diff --git a/test/Spec.hs b/test/Spec.hs
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -45,17 +45,17 @@
       it "allows a command to be specified with a package" $
         theOptions "-p python --command cowsay"
           `shouldBe`
-        Right def{packages=["python"], command=Just "cowsay"}
+        Right def{packages=Packages ["python"], command=Just "cowsay"}
 
       it "allows a command to be specified before a package" $
         theOptions "--run cowsay -p python"
           `shouldBe`
-        Right def{packages=["python"], command=Just "cowsay"}
+        Right def{packages=Packages ["python"], command=Just "cowsay"}
 
       it "allows a command to be specified before and after a package" $
         theOptions "-p cowsay --command cowsay -p python"
           `shouldBe`
-        Right def{packages=[ "cowsay", "python" ], command=Just "cowsay"}
+        Right def{packages=Packages [ "cowsay", "python" ], command=Just "cowsay"}
 
       it "fails if command has no argument" $ do
         shellifyWithArgs "--command -p python"
@@ -96,7 +96,7 @@
     it "supports new shell commands" $
       theOptions "shell nixpkgs#python nixpkgs#cowsay"
         `shouldBe`
-      Right def{packages=[ "nixpkgs#python", "nixpkgs#cowsay" ], generateFlake=True}
+      Right def{packages=Packages [ "nixpkgs#python", "nixpkgs#cowsay" ], outputForm=Flake}
 
   describe "When dealing with multiple source repositories it should produce the correct output files for" $ do
 
diff --git a/test/TestHelpers.hs b/test/TestHelpers.hs
--- a/test/TestHelpers.hs
+++ b/test/TestHelpers.hs
@@ -1,10 +1,9 @@
 module TestHelpers where
 
-import Prelude hiding (last, putStrLn, readFile, reverse, tail, unlines, words)
-import Data.Bool (bool)
-import Data.Text (isInfixOf, last, reverse, tail, Text(), unpack, unlines, words)
-import Data.Text.IO (putStrLn, readFile)
-import Test.Hspec (Expectation(), expectationFailure, it, shouldBe, shouldContain)
+import Prelude hiding (readFile, unlines, words)
+import Data.Text (Text(), unpack, unlines, words)
+import Data.Text.IO (readFile)
+import Test.Hspec (Expectation(), expectationFailure, shouldBe, shouldContain)
 import Options
 import Shellify
 import TemplateGeneration
@@ -129,18 +128,12 @@
 shouldResultInPackages parameters packages =
      theOptions parameters
        `shouldBe`
-     Right def{packages=packages}
+     Right def{packages=Packages packages}
 
 theOptions = options "nix-shellify" . words
 
-instance Show Options
-
 readNixTemplate :: FilePath -> IO Text
-readNixTemplate fileName =
-    stripTrailingNewline <$> readFile ("test/outputs/" <> fileName)
-    where stripTrailingNewline f = bool id stripLastChar (lastCharIsNewline f) f
-          lastCharIsNewline = (== '\n') . last
-          stripLastChar = reverse . tail . reverse
+readNixTemplate fileName = readFile ("test/outputs/" <> fileName)
 
 flakeFile = (<> "-flake.nix")
 shellFile = (<> "-shell.nix")
diff --git a/test/outputs/cowsay-from-nixpkgs-with-niv-shell.nix b/test/outputs/cowsay-from-nixpkgs-with-niv-shell.nix
new file mode 100644
--- /dev/null
+++ b/test/outputs/cowsay-from-nixpkgs-with-niv-shell.nix
@@ -0,0 +1,10 @@
+{ sources ? import ./nix/sources.nix }:
+
+let pkgs = import sources.nixpkgs {};
+in pkgs.mkShell {
+
+  buildInputs = [
+    pkgs.cowsay
+  ];
+
+}
