-|
  Saves string to given file on a new line.
  If file or subdirectory does not exist,
  directory and/or file will be created.
  File is relative to execution directory
  and will be saved at: db/filename.ext
-}
appendDataToFileLn :: String -> String -> IO ()
appendDataToFileLn str2write fileName = do
    createDirectoryIfMissing True "db" 
    appendFile file $ str2write ++ "\n"
    where 
      file = "db" ++ pathSeparator:(takeFileName fileName)


{-|
  Reads a newline separated file
  and returns an array of strings 
  where each string is a line in the file.
  File is relative to execution directory
  and must exist in subfolder "db".
-}

appendDataToFileLn :: String -> String -> IO ()
appendDataToFileLn str2write fileName = do
    createDirectoryIfMissing True "db" 
    appendFile file $ str2write ++ "\n"
    where 
      file = "db" ++ pathSeparator:(takeFileName fileName)


{-|
  Reads a newline separated file
  and returns an array of strings 
  where each string is a line in the file.
  File is relative to execution directory
  and must exist in subfolder "db".
-}
appendDataToFileLn str2write fileName = do
    createDirectoryIfMissing True "db" 
    appendFile file $ str2write ++ "\n"
    where 
      file = "db" ++ pathSeparator:(takeFileName fileName)


{-|
  Reads a newline separated file
  and returns an array of strings 
  where each string is a line in the file.
  File is relative to execution directory
  and must exist in subfolder "db".
-}